home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / technote / tn_200.hqx / TN.200.MPW 2.0.2 Bugs
Unknown  |  1988-10-17  |  48.0 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text


This file was not able to be converted.
This format is not currently supported by dexvert.

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert Jesper Olsen Module (music/jesperOlsen) magic Supported
1% dexvert TTComp Archive (archive/ttcomp) fallback Supported
100% file TTComp archive data, binary, 4K dictionary default (weak)
99% file data default
100% TrID TTComp archive compressed (bin-4K) default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 06 02 7c 00 01 00 03 | 00 00 00 ff ff 00 ff fc |...|....|........|
|00000010| 00 01 00 00 bf 34 00 e0 | 00 e0 00 00 bf 10 00 c0 |.....4..|........|
|00000020| 00 c0 00 00 be e6 00 c0 | 00 03 00 00 00 48 00 48 |........|.....H.H|
|00000030| 00 00 00 00 02 da 02 28 | ff e1 ff e2 02 f9 02 46 |.......(|.......F|
|00000040| 03 47 05 28 03 fc 00 02 | 00 00 00 48 00 48 00 00 |.G.(....|...H.H..|
|00000050| 00 00 02 da 02 28 00 01 | 00 00 00 64 00 00 00 01 |.....(..|...d....|
|00000060| 00 01 01 01 00 00 00 0d | 7d 00 00 01 00 01 00 2e |........|}.......|
|00000070| aa 9c 00 2e ab 28 80 23 | 00 00 00 02 00 19 01 90 |.....(.#|........|
|00000080| 00 00 00 00 00 40 00 00 | 00 00 00 00 00 00 00 00 |.....@..|........|
|00000090| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000a0| 00 02 00 1f 00 02 00 1f | 00 00 00 00 00 00 89 24 |........|.......$|
|000000b0| 00 30 00 00 84 7a 00 0e | 00 3c 00 f1 ff f2 00 f4 |.0...z..|.<......|
|000000c0| ff f2 01 c2 ff fb 00 00 | 00 00 ff ff ff ff 00 01 |........|........|
|000000d0| 00 00 00 01 00 00 00 00 | 00 00 00 00 87 82 00 10 |........|........|
|000000e0| 00 00 01 48 00 02 ff f2 | 00 26 ff f2 00 f4 ff f2 |...H....|.&......|
|000000f0| 01 c2 ff fb 00 00 00 00 | ff ff ff ff 00 25 00 00 |........|.....%..|
|00000100| 00 25 00 00 fc c9 00 1e | 00 00 97 74 27 c0 00 00 |.%......|...t'...|
|00000110| 89 54 0e 20 ff f2 00 26 | ff f2 00 f4 ff f2 01 c2 |.T. ...&|........|
|00000120| 00 00 00 00 ff 00 09 00 | 00 16 00 00 02 1c 03 02 |........|........|
|00000130| 00 01 0d 25 00 06 00 00 | 0c 00 00 15 00 01 0d 01 |...%....|........|
|00000140| 00 06 00 00 0e 00 00 15 | 00 00 00 00 00 01 0d 00 |........|........|
|00000150| 00 06 00 00 0a 00 00 15 | 00 34 f5 41 cb 37 c6 a0 |........|.4.A.7..|
|00000160| f4 e5 21 0f 23 f3 2f 30 | f3 00 f0 9e 6f 67 10 00 |..!.#./0|....og..|
|00000170| 00 00 5d 0f 31 f3 4f 09 | f4 df 50 f5 70 f3 2f 2e |..].1.O.|..P.p./.|
|00000180| f3 0f 2e f3 20 f4 2f 75 | f6 78 00 06 00 00 0a 00 |.... ./u|.x......|
|00000190| 00 15 00 49 09 3b 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |...I.;--|--------|
|000001a0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000001b0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000001c0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000001d0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 0d ff 00 06 |--------|----....|
|000001e0| 00 00 09 00 00 16 00 16 | 00 00 00 06 00 00 0c 00 |........|........|
|000001f0| 00 15 73 09 00 0b 09 09 | 65 78 69 74 28 30 29 3b |..s.....|exit(0);|
|00000200| 0d 00 00 06 00 00 09 00 | 00 16 00 15 00 01 0d 61 |........|.......a|
|00000210| 00 06 00 00 0e 00 00 15 | 00 15 23 32 30 30 3a 09 |........|..#200:.|
|00000220| 4d 50 57 20 32 2e 30 2e | 32 20 42 75 67 73 0d 32 |MPW 2.0.|2 Bugs.2|
|00000230| 00 06 00 00 0e 00 00 15 | 00 01 0d 06 00 06 00 00 |........|........|
|00000240| 0e 00 00 15 00 29 57 72 | 69 74 74 65 6e 20 62 79 |.....)Wr|itten by|
|00000250| 3a 09 44 61 76 65 20 42 | 75 72 6e 61 72 64 09 09 |:.Dave B|urnard..|
|00000260| 41 75 67 75 73 74 20 31 | 2c 20 31 39 38 38 0d 15 |August 1|, 1988..|
|00000270| 00 06 00 00 0e 00 00 15 | 00 2c 4d 6f 64 69 66 69 |........|.,Modifi|
|00000280| 65 64 20 62 79 3a 09 41 | 6e 64 79 20 53 68 65 62 |ed by:.A|ndy Sheb|
|00000290| 61 6e 6f 77 09 09 4f 63 | 74 6f 62 65 72 20 31 2c |anow..Oc|tober 1,|
|000002a0| 20 31 39 38 38 0d 00 06 | 00 00 0e 00 00 15 00 1e | 1988...|........|
|000002b0| f4 d6 c7 32 58 b0 f5 41 | cb 37 c6 a0 f4 e5 21 8f |...2X..A|.7....!.|
|000002c0| 09 f0 9f 09 ff 0f 0d 00 | 00 12 00 00 0e 01 00 15 |........|........|
|000002d0| 00 19 0e 00 00 15 00 1c | 18 10 00 15 00 01 0d 00 |........|........|
|000002e0| 00 06 00 00 0e 00 00 15 | 01 cd 54 68 69 73 20 54 |........|..This T|
|000002f0| 65 63 68 6e 69 63 61 6c | 20 4e 6f 74 65 20 64 65 |echnical| Note de|
|00000300| 73 63 72 69 62 65 73 20 | 6c 61 74 65 73 74 20 69 |scribes |latest i|
|00000310| 6e 66 6f 72 6d 61 74 69 | 6f 6e 20 61 62 6f 75 74 |nformati|on about|
|00000320| 20 62 75 67 73 20 6f 72 | 20 75 6e 65 78 70 65 63 | bugs or| unexpec|
|00000330| 74 65 64 20 d2 66 65 61 | 74 75 72 65 73 d3 20 69 |ted .fea|tures. i|
|00000340| 6e 20 74 68 65 20 4d 50 | 57 20 43 2c 20 50 61 73 |n the MP|W C, Pas|
|00000350| 63 61 6c 2c 20 61 6e 64 | 20 41 73 73 65 6d 62 6c |cal, and| Assembl|
|00000360| 65 72 20 70 72 6f 64 75 | 63 74 73 20 61 6e 64 20 |er produ|cts and |
|00000370| 74 68 65 20 54 6f 6f 6c | 62 6f 78 20 61 6e 64 20 |the Tool|box and |
|00000380| 4f 53 20 49 6e 74 65 72 | 66 61 63 65 20 4c 69 62 |OS Inter|face Lib|
|00000390| 72 61 72 69 65 73 2e 20 | 20 57 65 20 69 6e 74 65 |raries. | We inte|
|000003a0| 6e 64 20 74 68 69 73 20 | 4e 6f 74 65 20 74 6f 20 |nd this |Note to |
|000003b0| 62 65 20 61 20 63 6f 6d | 70 6c 65 74 65 20 6c 69 |be a com|plete li|
|000003c0| 73 74 20 6f 66 20 61 6c | 6c 20 6b 6e 6f 77 6e 20 |st of al|l known |
|000003d0| 62 75 67 73 20 69 6e 20 | 74 68 65 73 65 20 70 72 |bugs in |these pr|
|000003e0| 6f 64 75 63 74 73 2c 20 | 77 68 69 63 68 20 77 69 |oducts, |which wi|
|000003f0| 6c 6c 20 62 65 20 75 70 | 64 61 74 65 64 20 61 73 |ll be up|dated as|
|00000400| 20 6f 6c 64 20 62 75 67 | 73 20 61 72 65 20 66 69 | old bug|s are fi|
|00000410| 78 65 64 2c 20 6f 72 20 | 6e 65 77 20 6f 6e 65 73 |xed, or |new ones|
|00000420| 20 61 70 70 65 61 72 2e | 20 20 49 66 20 79 6f 75 | appear.| If you|
|00000430| 20 68 61 76 65 20 65 6e | 63 6f 75 6e 74 65 72 65 | have en|countere|
|00000440| 64 20 61 20 62 75 67 20 | 6f 72 20 75 6e 65 78 70 |d a bug |or unexp|
|00000450| 65 63 74 65 64 20 66 65 | 61 74 75 72 65 20 77 68 |ected fe|ature wh|
|00000460| 69 63 68 20 69 73 20 6e | 6f 74 20 64 65 73 63 72 |ich is n|ot descr|
|00000470| 69 62 65 64 20 68 65 72 | 65 2c 20 62 65 20 73 75 |ibed her|e, be su|
|00000480| 72 65 20 74 6f 20 6c 65 | 74 20 75 73 20 6b 6e 6f |re to le|t us kno|
|00000490| 77 2e 20 20 53 70 65 63 | 69 66 69 63 20 63 6f 64 |w. Spec|ific cod|
|000004a0| 65 20 65 78 61 6d 70 6c | 65 73 20 61 72 65 20 75 |e exampl|es are u|
|000004b0| 73 65 66 75 6c 2e 0d 00 | 00 06 00 00 0e 00 00 15 |seful...|........|
|000004c0| 00 01 0d 00 00 06 00 00 | 0e 00 00 15 00 7b 54 68 |........|.....{Th|
|000004d0| 65 20 62 75 67 73 20 64 | 65 73 63 72 69 62 65 64 |e bugs d|escribed|
|000004e0| 20 69 6e 20 74 68 65 20 | 4f 63 74 6f 62 65 72 20 | in the |October |
|000004f0| 31 20 72 65 76 69 73 69 | 6f 6e 20 6f 66 20 74 68 |1 revisi|on of th|
|00000500| 69 73 20 4e 6f 74 65 20 | 77 69 6c 6c 20 62 65 20 |is Note |will be |
|00000510| 66 69 78 65 64 20 69 6e | 20 74 68 65 20 33 2e 30 |fixed in| the 3.0|
|00000520| 20 72 65 6c 65 61 73 65 | 20 6f 66 20 4d 50 57 20 | release| of MPW |
|00000530| 73 63 68 65 64 75 6c 65 | 64 20 66 6f 72 20 46 61 |schedule|d for Fa|
|00000540| 6c 6c 20 31 39 38 38 2e | 0d ff 00 06 00 00 0e 00 |ll 1988.|........|
|00000550| 00 15 00 01 0d ff 00 06 | 00 00 0e 00 00 15 01 06 |........|........|
|00000560| 43 68 61 6e 67 65 73 20 | 73 69 6e 63 65 20 41 75 |Changes |since Au|
|00000570| 67 75 73 74 20 31 2c 20 | 31 39 38 38 3a 20 20 43 |gust 1, |1988: C|
|00000580| 6f 72 72 65 63 74 65 64 | 20 74 68 65 20 64 65 73 |orrected| the des|
|00000590| 63 72 69 70 74 69 6f 6e | 20 6f 66 20 d2 62 75 67 |cription| of .bug|
|000005a0| d3 20 23 33 20 75 6e 64 | 65 72 20 4d 50 57 20 43 |. #3 und|er MPW C|
|000005b0| 20 61 73 20 69 74 20 69 | 73 20 6e 6f 74 20 61 20 | as it i|s not a |
|000005c0| 62 75 67 20 61 63 63 6f | 72 64 69 6e 67 20 74 6f |bug acco|rding to|
|000005d0| 20 74 68 65 20 64 65 66 | 69 6e 69 74 69 6f 6e 20 | the def|inition |
|000005e0| 6f 66 20 74 68 65 20 43 | 20 6c 61 6e 67 75 61 67 |of the C| languag|
|000005f0| 65 20 61 6e 64 20 63 6f | 72 72 65 63 74 65 64 20 |e and co|rrected |
|00000600| 61 6e 20 65 72 72 6f 72 | 20 69 6e 20 62 75 67 20 |an error| in bug |
|00000610| 23 32 20 6f 66 20 74 68 | 65 20 49 6e 74 65 72 66 |#2 of th|e Interf|
|00000620| 61 63 65 20 4c 69 62 72 | 61 72 69 65 73 20 63 6f |ace Libr|aries co|
|00000630| 6e 63 65 72 6e 69 6e 67 | 20 74 68 65 20 67 6c 75 |ncerning| the glu|
|00000640| 65 20 66 6f 72 20 5f 53 | 6c 6f 74 56 49 6e 73 74 |e for _S|lotVInst|
|00000650| 61 6c 6c 20 61 6e 64 20 | 5f 53 6c 6f 74 56 52 65 |all and |_SlotVRe|
|00000660| 6d 6f 76 65 2e 0d 00 24 | 00 00 0e 01 00 15 00 1d |move...$|........|
|00000670| 0e 00 00 15 00 e6 0e 00 | 00 16 00 f3 0e 00 00 15 |........|........|
|00000680| 00 f8 0e 00 00 16 01 04 | 0e 00 00 15 00 01 0d 48 |........|.......H|
|00000690| 00 06 00 00 09 00 00 16 | 00 14 f4 93 21 4d 6c 10 |........|....!Ml.|
|000006a0| f4 c7 f6 24 64 71 8f 0d | 00 06 00 00 0e 01 00 15 |...$dq..|........|
|000006b0| 00 0b 43 20 4c 61 6e 67 | 75 61 67 65 0d ff 00 06 |..C Lang|uage....|
|000006c0| 00 00 0e 01 00 15 00 01 | 0d ff 00 06 00 00 0c 00 |........|........|
|000006d0| 00 15 00 78 54 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |...xThe |followin|
|000006e0| 67 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 20 61 70 |g inform|ation ap|
|000006f0| 70 6c 69 65 73 20 74 6f | 20 74 68 65 20 43 20 63 |plies to| the C c|
|00000700| 6f 6d 70 69 6c 65 72 20 | 61 6e 64 20 69 74 73 20 |ompiler |and its |
|00000710| 61 73 73 6f 63 69 61 74 | 65 64 20 6c 69 62 72 61 |associat|ed libra|
|00000720| 72 69 65 73 20 73 68 69 | 70 70 65 64 20 77 69 74 |ries shi|pped wit|
|00000730| 68 20 74 68 65 20 32 2e | 30 2e 32 20 76 65 72 73 |h the 2.|0.2 vers|
|00000740| 69 6f 6e 20 6f 66 20 4d | 50 57 2e 0d 00 06 00 00 |ion of M|PW......|
|00000750| 0c 00 00 15 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |........|........|
|00000760| 00 12 01 e6 03 06 00 00 | 00 12 00 3a 00 82 00 a6 |........|...:....|
|00000770| 01 0e 01 71 01 cb 02 26 | 02 26 00 00 00 00 00 00 |...q...&|.&......|
|00000780| 00 00 01 ac 31 29 09 41 | 20 73 65 72 69 65 73 20 |....1).A| series |
|00000790| 6f 66 20 62 75 67 73 20 | 69 6e 76 6f 6c 76 69 6e |of bugs |involvin|
|000007a0| 67 20 66 6c 6f 61 74 69 | 6e 67 20 70 6f 69 6e 74 |g floati|ng point|
|000007b0| 20 61 72 72 61 79 20 65 | 6c 65 6d 65 6e 74 73 20 | array e|lements |
|000007c0| 61 6e 64 20 74 68 65 20 | 2b 3d 2c 20 2a 3d 2c 20 |and the |+=, *=, |
|000007d0| 61 6e 64 20 3d 20 6f 70 | 65 72 61 74 6f 72 73 2e |and = op|erators.|
|000007e0| 20 20 41 20 73 69 6d 69 | 6c 61 72 20 62 75 67 20 | A simi|lar bug |
|000007f0| 77 61 73 20 72 65 70 6f | 72 74 65 64 20 61 73 20 |was repo|rted as |
|00000800| 66 69 78 65 64 20 69 6e | 20 4d 50 57 20 32 2e 30 |fixed in| MPW 2.0|
|00000810| 2e 32 2c 20 75 6e 66 6f | 72 74 75 6e 61 74 65 6c |.2, unfo|rtunatel|
|00000820| 79 20 74 68 65 20 66 69 | 78 20 64 69 64 20 6e 6f |y the fi|x did no|
|00000830| 74 20 61 70 70 6c 79 20 | 74 6f 20 61 72 72 61 79 |t apply |to array|
|00000840| 20 65 6c 65 6d 65 6e 74 | 73 2e 20 20 54 68 69 73 | element|s. This|
|00000850| 20 62 75 67 20 4f 4e 4c | 59 20 6f 63 63 75 72 73 | bug ONL|Y occurs|
|00000860| 20 77 68 65 6e 20 75 73 | 69 6e 67 20 53 41 4e 45 | when us|ing SANE|
|00000870| 20 69 6e 20 63 6f 6d 62 | 69 6e 61 74 69 6f 6e 20 | in comb|ination |
|00000880| 77 69 74 68 20 66 6c 6f | 61 74 20 6f 72 20 64 6f |with flo|at or do|
|00000890| 75 62 6c 65 20 76 61 72 | 69 61 62 6c 65 73 2c 20 |uble var|iables, |
|000008a0| 69 74 20 64 6f 65 73 20 | 6e 6f 74 20 6f 63 63 75 |it does |not occu|
|000008b0| 72 20 69 66 20 74 68 65 | 20 2d 6d 63 36 38 38 38 |r if the| -mc6888|
|000008c0| 31 20 63 6f 6d 70 69 6c | 65 72 20 6f 70 74 69 6f |1 compil|er optio|
|000008d0| 6e 20 69 73 20 73 70 65 | 63 69 66 69 65 64 20 6f |n is spe|cified o|
|000008e0| 72 20 69 66 20 65 78 74 | 65 6e 64 65 64 20 76 61 |r if ext|ended va|
|000008f0| 72 69 61 62 6c 65 73 20 | 61 72 65 20 75 73 65 64 |riables |are used|
|00000900| 2e 20 20 54 68 65 20 66 | 6f 6c 6c 6f 77 69 6e 67 |. The f|ollowing|
|00000910| 20 66 72 61 67 6d 65 6e | 74 20 69 6c 6c 75 73 74 | fragmen|t illust|
|00000920| 72 61 74 65 73 20 74 68 | 65 20 62 75 67 73 3a 0d |rates th|e bugs:.|
|00000930| 00 5a 00 00 0c 00 00 15 | 00 44 0c 00 00 16 00 46 |.Z......|.D.....F|
|00000940| 0c 00 00 15 00 48 0c 00 | 00 16 00 4b 0c 00 00 15 |.....H..|...K....|
|00000950| 00 50 0c 00 00 16 00 52 | 0c 00 00 15 01 01 0c 00 |.P.....R|........|
|00000960| 00 16 01 06 0c 00 00 15 | 01 0a 0c 00 00 16 01 10 |........|........|
|00000970| 0c 00 00 15 01 35 0c 00 | 00 16 01 3d 0c 00 00 15 |.....5..|...=....|
|00000980| 01 61 0c 00 00 16 01 69 | 0c 00 00 15 00 01 0d 00 |.a.....i|........|
|00000990| 00 06 00 00 0c 00 00 15 | 00 12 01 e6 03 0a 00 00 |........|........|
|000009a0| 00 12 00 31 00 5a 00 82 | 00 a6 00 cf 00 f7 01 20 |...1.Z..|....... |
|000009b0| 01 48 01 71 01 99 02 26 | 02 26 00 08 09 6d 61 69 |.H.q...&|.&...mai|
|000009c0| 6e 28 29 0d 00 06 00 00 | 09 00 00 16 00 03 09 7b |n().....|.......{|
|000009d0| 0d 00 00 06 00 00 09 00 | 00 16 00 3a 09 09 64 6f |........|...:..do|
|000009e0| 75 62 6c 65 20 78 5b 32 | 5d 2c 79 3b 20 20 2f 2a |uble x[2|],y; /*|
|000009f0| 20 41 6c 73 6f 20 66 61 | 69 6c 73 20 69 66 20 78 | Also fa|ils if x|
|00000a00| 2c 79 20 61 72 65 20 64 | 65 63 6c 61 72 65 64 20 |,y are d|eclared |
|00000a10| 66 6c 6f 61 74 0d 00 06 | 00 00 09 00 00 16 00 2a |float...|.......*|
|00000a20| 09 09 09 09 09 62 75 74 | 20 73 75 63 63 65 65 64 |.....but| succeed|
|00000a30| 73 20 69 66 20 64 65 63 | 6c 61 72 65 64 20 65 78 |s if dec|lared ex|
|00000a40| 74 65 6e 64 65 64 20 2a | 2f 0d 00 06 00 00 09 00 |tended *|/.......|
|00000a50| 00 16 00 0e 09 09 78 5b | 30 5d 20 3d 20 30 2e 35 |......x[|0] = 0.5|
|00000a60| 3b 0d 00 06 00 00 09 00 | 00 16 00 0b 09 09 79 20 |;.......|......y |
|00000a70| 3d 20 35 2e 30 3b 0d 00 | 00 06 00 00 09 00 00 16 |= 5.0;..|........|
|00000a80| 00 11 09 09 78 5b 30 5d | 20 2b 3d 20 32 2e 30 2a |....x[0]| += 2.0*|
|00000a90| 79 3b 0d 00 00 06 00 00 | 09 00 00 16 00 1f 09 09 |y;......|........|
|00000aa0| 70 72 69 6e 74 66 28 22 | 78 5b 30 5d 20 3d 20 25 |printf("|x[0] = %|
|00000ab0| 66 5c 6e 22 2c 20 78 5b | 30 5d 29 3b 0d 00 00 06 |f\n", x[|0]);....|
|00000ac0| 00 00 09 00 00 16 00 02 | 09 0d 00 06 00 00 09 00 |........|........|
|00000ad0| 00 16 00 0e 09 09 78 5b | 30 5d 20 3d 20 30 2e 35 |......x[|0] = 0.5|
|00000ae0| 3b 0d 00 06 00 00 09 00 | 00 16 00 0b 09 09 79 20 |;.......|......y |
|00000af0| 3d 20 35 2e 30 3b 0d 00 | 00 06 00 00 09 00 00 16 |= 5.0;..|........|
|00000b00| 00 17 09 09 78 5b 30 5d | 20 3d 20 78 5b 30 5d 20 |....x[0]| = x[0] |
|00000b10| 2b 20 32 2e 30 2a 79 3b | 0d 00 00 06 00 00 09 00 |+ 2.0*y;|........|
|00000b20| 00 16 00 1f 09 09 70 72 | 69 6e 74 66 28 22 78 5b |......pr|intf("x[|
|00000b30| 30 5d 20 3d 20 25 66 5c | 6e 22 2c 20 78 5b 30 5d |0] = %f\|n", x[0]|
|00000b40| 29 3b 0d 00 00 06 00 00 | 09 00 00 16 00 02 09 0d |);......|........|
|00000b50| 00 06 00 00 09 00 00 16 | 00 0e 09 09 78 5b 30 5d |........|....x[0]|
|00000b60| 20 3d 20 30 2e 35 3b 0d | 00 06 00 00 09 00 00 16 | = 0.5;.|........|
|00000b70| 00 0b 09 09 79 20 3d 20 | 35 2e 30 3b 0d 00 00 06 |....y = |5.0;....|
|00000b80| 00 00 09 00 00 16 00 11 | 09 09 78 5b 30 5d 20 2a |........|..x[0] *|
|00000b90| 3d 20 32 2e 30 2a 79 3b | 0d 00 00 06 00 00 09 00 |= 2.0*y;|........|
|00000ba0| 00 16 00 1f 09 09 70 72 | 69 6e 74 66 28 22 78 5b |......pr|intf("x[|
|00000bb0| 30 5d 20 3d 20 25 66 5c | 6e 22 2c 20 78 5b 30 5d |0] = %f\|n", x[0]|
|00000bc0| 29 3b 0d 00 00 06 00 00 | 09 00 00 16 00 02 09 0d |);......|........|
|00000bd0| 00 06 00 00 09 00 00 16 | 00 0e 09 09 78 5b 30 5d |........|....x[0]|
|00000be0| 20 3d 20 30 2e 35 3b 0d | 00 06 00 00 09 00 00 16 | = 0.5;.|........|
|00000bf0| 00 0b 09 09 79 20 3d 20 | 35 2e 30 3b 0d 00 00 06 |....y = |5.0;....|
|00000c00| 00 00 09 00 00 16 00 41 | 09 09 78 5b 30 5d 20 3d |.......A|..x[0] =|
|00000c10| 20 78 5b 30 5d 2a 28 32 | 2e 30 2a 79 29 3b 09 2f | x[0]*(2|.0*y);./|
|00000c20| 2a 20 53 75 63 63 65 65 | 64 73 20 69 66 20 70 61 |* Succee|ds if pa|
|00000c30| 72 65 6e 74 68 65 73 69 | 73 20 61 72 65 20 72 65 |renthesi|s are re|
|00000c40| 6d 6f 76 65 64 20 2a 2f | 0d 00 00 06 00 00 09 00 |moved */|........|
|00000c50| 00 16 00 1f 09 09 70 72 | 69 6e 74 66 28 22 78 5b |......pr|intf("x[|
|00000c60| 30 5d 20 3d 20 25 66 5c | 6e 22 2c 20 78 5b 30 5d |0] = %f\|n", x[0]|
|00000c70| 29 3b 0d 00 00 06 00 00 | 09 00 00 16 00 02 09 0d |);......|........|
|00000c80| 00 06 00 00 09 00 00 16 | 00 00 00 08 00 19 03 f0 |........|........|
|00000c90| 00 0d 4d 41 47 49 43 50 | 49 43 11 01 ff 96 7d 00 |..MAGICP|IC....}.|
|00000ca0| 24 01 e6 03 0a 00 00 00 | 12 00 31 00 5a 00 82 00 |$.......|..1.Z...|
|00000cb0| a6 00 cf 00 f7 01 20 01 | 48 01 71 01 99 02 26 02 |...... .|H.q...&.|
|00000cc0| 26 00 00 01 0d 00 00 06 | 00 00 09 00 00 16 00 12 |&.......|........|
|00000cd0| 01 e6 03 0a 00 00 00 12 | 00 31 00 5a 00 82 00 a6 |........|.1.Z....|
|00000ce0| 00 cf 00 f7 01 20 01 48 | 01 71 01 99 02 10 02 10 |..... .H|.q......|
|00000cf0| 00 01 0d 00 00 06 00 00 | 0c 00 00 15 00 75 09 54 |........|.....u.T|
|00000d00| 68 69 73 20 63 6f 64 65 | 20 66 72 61 67 6d 65 6e |his code| fragmen|
|00000d10| 74 20 72 65 74 75 72 6e | 73 20 74 68 65 20 65 72 |t return|s the er|
|00000d20| 72 6f 6e 65 6f 75 73 20 | 76 61 6c 75 65 73 20 30 |roneous |values 0|
|00000d30| 2e 35 2c 20 30 2e 35 2c | 20 30 2e 35 2c 20 30 2e |.5, 0.5,| 0.5, 0.|
|00000d40| 35 20 28 74 68 65 20 63 | 6f 72 72 65 63 74 20 76 |5 (the c|orrect v|
|00000d50| 61 6c 75 65 73 20 61 72 | 65 20 31 30 2e 35 2c 31 |alues ar|e 10.5,1|
|00000d60| 30 2e 35 2c 20 35 2e 30 | 20 61 6e 64 20 35 2e 30 |0.5, 5.0| and 5.0|
|00000d70| 29 2e 0d 00 00 06 00 00 | 0c 00 00 15 00 01 0d 00 |).......|........|
|00000d80| 00 06 00 00 0c 00 00 15 | 00 49 09 57 6f 72 6b 61 |........|.I.Worka|
|00000d90| 72 6f 75 6e 64 3a 20 20 | 49 66 20 75 73 69 6e 67 |round: |If using|
|00000da0| 20 53 41 4e 45 2c 20 75 | 73 65 20 65 78 74 65 6e | SANE, u|se exten|
|00000db0| 64 65 64 20 76 61 72 69 | 61 62 6c 65 73 20 69 6e |ded vari|ables in|
|00000dc0| 20 74 68 65 73 65 20 73 | 69 74 75 61 74 69 6f 6e | these s|ituation|
|00000dd0| 73 2e 0d 00 00 18 00 00 | 0c 01 00 15 00 0c 0c 00 |s.......|........|
|00000de0| 00 15 00 21 0c 00 00 16 | 00 29 0c 00 00 15 00 01 |...!....|.)......|
|00000df0| 0d 00 00 06 00 00 0c 00 | 00 15 01 65 32 29 09 54 |........|...e2).T|
|00000e00| 61 6b 69 6e 67 20 74 68 | 65 20 61 64 64 72 65 73 |aking th|e addres|
|00000e10| 73 20 6f 66 20 61 20 66 | 6c 6f 61 74 69 6e 67 20 |s of a f|loating |
|00000e20| 70 6f 69 6e 74 20 66 6f | 72 6d 61 6c 20 70 61 72 |point fo|rmal par|
|00000e30| 61 6d 65 74 65 72 20 28 | 66 75 6e 63 74 69 6f 6e |ameter (|function|
|00000e40| 20 61 72 67 75 6d 65 6e | 74 29 20 74 6f 20 61 20 | argumen|t) to a |
|00000e50| 66 75 6e 63 74 69 6f 6e | 20 66 61 69 6c 73 2e 20 |function| fails. |
|00000e60| 20 54 68 69 73 20 62 75 | 67 20 6f 63 63 75 72 73 | This bu|g occurs|
|00000e70| 20 77 68 65 6e 20 75 73 | 69 6e 67 20 65 69 74 68 | when us|ing eith|
|00000e80| 65 72 20 53 41 4e 45 20 | 6f 72 20 74 68 65 20 2d |er SANE |or the -|
|00000e90| 6d 63 36 38 38 38 31 20 | 63 6f 6d 70 69 6c 65 72 |mc68881 |compiler|
|00000ea0| 20 6f 70 74 69 6f 6e 20 | 69 6e 20 63 6f 6d 62 69 | option |in combi|
|00000eb0| 6e 61 74 69 6f 6e 20 77 | 69 74 68 20 66 6c 6f 61 |nation w|ith floa|
|00000ec0| 74 20 6f 72 20 64 6f 75 | 62 6c 65 20 66 75 6e 63 |t or dou|ble func|
|00000ed0| 74 69 6f 6e 20 61 72 67 | 75 6d 65 6e 74 73 2c 20 |tion arg|uments, |
|00000ee0| 69 74 20 64 6f 65 73 20 | 6e 6f 74 20 6f 63 63 75 |it does |not occu|
|00000ef0| 72 20 69 66 20 74 68 65 | 20 66 75 6e 63 74 69 6f |r if the| functio|
|00000f00| 6e 20 61 72 67 75 6d 65 | 6e 74 73 20 61 72 65 20 |n argume|nts are |
|00000f10| 64 65 63 6c 61 72 65 64 | 20 65 78 74 65 6e 64 65 |declared| extende|
|00000f20| 64 2e 20 54 68 65 20 66 | 6f 6c 6c 6f 77 69 6e 67 |d. The f|ollowing|
|00000f30| 20 66 72 61 67 6d 65 6e | 74 20 69 6c 6c 75 73 74 | fragmen|t illust|
|00000f40| 72 61 74 65 73 20 74 77 | 6f 20 69 6e 73 74 61 6e |rates tw|o instan|
|00000f50| 63 65 73 20 6f 66 20 74 | 68 69 73 20 62 75 67 3a |ces of t|his bug:|
|00000f60| 0d 00 00 36 00 00 0c 00 | 00 15 00 93 0c 00 00 16 |...6....|........|
|00000f70| 00 9b 0c 00 00 15 00 c0 | 0c 00 00 16 00 c5 0c 00 |........|........|
|00000f80| 00 15 00 c9 0c 00 00 16 | 00 cf 0c 00 00 15 01 1d |........|........|
|00000f90| 0c 00 00 16 01 25 0c 00 | 00 15 00 01 0d 00 00 06 |.....%..|........|
|00000fa0| 00 00 0c 00 00 15 00 24 | 01 e6 03 0a 00 00 00 12 |.......$|........|
|00000fb0| 00 31 00 5a 00 82 00 a6 | 00 cf 00 f7 01 20 01 48 |.1.Z....|..... .H|
|00000fc0| 01 71 01 99 02 26 02 26 | 00 14 09 23 69 6e 63 6c |.q...&.&|...#incl|
|00000fd0| 75 64 65 20 3c 54 79 70 | 65 73 2e 68 3e 0d 00 06 |ude <Typ|es.h>...|
|00000fe0| 00 00 09 00 00 16 00 13 | 09 23 69 6e 63 6c 75 64 |........|.#includ|
|00000ff0| 65 20 3c 4d 61 74 68 2e | 68 3e 0d 00 00 06 00 00 |e <Math.|h>......|
|00001000| 09 00 00 16 00 14 09 23 | 69 6e 63 6c 75 64 65 20 |.......#|include |
|00001010| 3c 73 74 64 69 6f 2e 68 | 3e 0d 00 06 00 00 09 00 |<stdio.h|>.......|
|00001020| 00 16 00 02 09 0d 00 06 | 00 00 09 00 00 16 00 3c |........|.......<|
|00001030| 09 23 64 65 66 69 6e 65 | 20 72 65 61 6c 20 66 6c |.#define| real fl|
|00001040| 6f 61 74 09 2f 2a 20 46 | 61 69 6c 73 20 77 69 74 |oat./* F|ails wit|
|00001050| 68 20 65 69 74 68 65 72 | 20 66 6c 6f 61 74 20 6f |h either| float o|
|00001060| 72 20 64 6f 75 62 6c 65 | 20 2a 2f 0d 00 06 00 00 |r double| */.....|
|00001070| 09 00 00 16 00 02 09 0d | 00 06 00 00 09 00 00 16 |........|........|
|00001080| 00 08 09 6d 61 69 6e 28 | 29 0d 00 06 00 00 09 00 |...main(|).......|
|00001090| 00 16 00 03 09 7b 0d 00 | 00 06 00 00 09 00 00 16 |.....{..|........|
|000010a0| 00 17 09 09 42 75 67 31 | 28 31 2e 30 2c 20 32 2e |....Bug1|(1.0, 2.|
|000010b0| 30 2c 20 33 2e 30 29 3b | 0d 00 00 06 00 00 09 00 |0, 3.0);|........|
|000010c0| 00 16 00 17 09 09 42 75 | 67 32 28 31 2e 30 2c 20 |......Bu|g2(1.0, |
|000010d0| 32 2e 30 2c 20 33 2e 30 | 29 3b 0d 00 00 06 00 00 |2.0, 3.0|);......|
|000010e0| 09 00 00 16 00 03 09 7d | 0d ff 00 06 00 00 09 00 |.......}|........|
|000010f0| 00 16 00 02 09 0d 00 06 | 00 00 09 00 00 16 00 10 |........|........|
|00001100| 09 42 75 67 31 20 28 78 | 2c 20 79 2c 20 7a 29 0d |.Bug1 (x|, y, z).|
|00001110| 00 06 00 00 09 00 00 16 | 00 10 09 09 72 65 61 6c |........|....real|
|00001120| 20 78 2c 20 79 2c 20 7a | 3b 0d 00 06 00 00 09 00 | x, y, z|;.......|
|00001130| 00 16 00 03 09 7b 0d ff | 00 06 00 00 09 00 00 16 |.....{..|........|
|00001140| 00 13 09 09 72 65 61 6c | 20 2a 70 2c 20 2a 71 2c |....real| *p, *q,|
|00001150| 20 2a 72 3b 0d ff 00 06 | 00 00 09 00 00 16 00 02 | *r;....|........|
|00001160| 09 0d 00 06 00 00 09 00 | 00 16 00 33 09 09 2f 2a |........|...3../*|
|00001170| 20 54 61 6b 65 20 61 64 | 64 72 65 73 73 20 6f 66 | Take ad|dress of|
|00001180| 20 61 72 67 75 6d 65 6e | 74 73 2c 20 61 73 73 69 | argumen|ts, assi|
|00001190| 67 6e 20 64 69 72 65 63 | 74 6c 79 20 2a 2f 0d ff |gn direc|tly */..|
|000011a0| 00 06 00 00 09 00 00 16 | 00 1a 09 09 70 20 3d 20 |........|....p = |
|000011b0| 26 78 3b 20 71 20 3d 20 | 26 79 3b 20 72 20 3d 20 |&x; q = |&y; r = |
|000011c0| 26 7a 3b 0d 00 06 00 00 | 09 00 00 16 00 02 09 0d |&z;.....|........|
|000011d0| 00 06 00 00 09 00 00 16 | 00 3f 09 09 66 70 72 69 |........|.?..fpri|
|000011e0| 6e 74 66 28 73 74 64 65 | 72 72 2c 20 22 45 78 61 |ntf(stde|rr, "Exa|
|000011f0| 6d 70 6c 65 20 31 3a 20 | 42 65 66 6f 72 65 3a 20 |mple 1: |Before: |
|00001200| 25 67 2c 20 25 67 2c 20 | 25 67 5c 6e 22 2c 20 78 |%g, %g, |%g\n", x|
|00001210| 2c 20 79 2c 20 7a 29 3b | 0d ff 00 06 00 00 09 00 |, y, z);|........|
|00001220| 00 16 00 0d 09 09 2a 70 | 20 3d 20 31 31 2e 30 3b |......*p| = 11.0;|
|00001230| 0d ff 00 06 00 00 09 00 | 00 16 00 0d 09 09 2a 71 |........|......*q|
|00001240| 20 3d 20 31 32 2e 30 3b | 0d ff 00 06 00 00 09 00 | = 12.0;|........|
|00001250| 00 16 00 0d 09 09 2a 72 | 20 3d 20 31 33 2e 30 3b |......*r| = 13.0;|
|00001260| 0d ff 00 06 00 00 09 00 | 00 16 00 3f 09 09 66 70 |........|...?..fp|
|00001270| 72 69 6e 74 66 28 73 74 | 64 65 72 72 2c 20 22 45 |rintf(st|derr, "E|
|00001280| 78 61 6d 70 6c 65 20 31 | 3a 20 41 66 74 65 72 3a |xample 1|: After:|
|00001290| 20 20 25 67 2c 20 25 67 | 2c 20 25 67 5c 6e 22 2c | %g, %g|, %g\n",|
|000012a0| 20 78 2c 20 79 2c 20 7a | 29 3b 0d 00 00 06 00 00 | x, y, z|);......|
|000012b0| 09 00 00 16 00 03 09 7d | 0d 00 00 06 00 00 09 00 |.......}|........|
|000012c0| 00 16 00 02 09 0d 00 06 | 00 00 09 00 00 16 00 00 |........|........|
|000012d0| ff d6 01 5e 03 be 00 0d | 4d 41 47 49 43 50 49 43 |...^....|MAGICPIC|
|000012e0| 11 01 ff 5f 09 00 00 16 | 00 10 09 09 72 65 61 6c |..._....|....real|
|000012f0| 20 78 2c 20 79 2c 20 7a | 3b 0d 00 06 00 00 09 00 | x, y, z|;.......|
|00001300| 00 16 00 03 09 7b 0d 00 | 00 06 00 00 09 00 00 16 |.....{..|........|
|00001310| 00 44 09 09 66 70 72 69 | 6e 74 66 28 73 74 64 65 |.D..fpri|ntf(stde|
|00001320| 72 72 2c 20 22 45 78 61 | 6d 70 6c 65 20 32 3a 20 |rr, "Exa|mple 2: |
|00001330| 42 75 67 32 20 42 65 66 | 6f 72 65 3a 20 25 67 2c |Bug2 Bef|ore: %g,|
|00001340| 20 25 67 2c 20 25 67 5c | 6e 22 2c 20 78 2c 20 79 | %g, %g\|n", x, y|
|00001350| 2c 20 7a 29 3b 0d 00 06 | 00 00 09 00 00 16 00 02 |, z);...|........|
|00001360| 09 0d 00 06 00 00 09 00 | 00 16 00 35 09 09 2f 2a |........|...5../*|
|00001370| 20 54 61 6b 65 20 61 64 | 64 72 65 73 73 20 6f 66 | Take ad|dress of|
|00001380| 20 61 72 67 75 6d 65 6e | 74 73 2c 20 61 73 73 69 | argumen|ts, assi|
|00001390| 67 6e 20 69 6e 64 69 72 | 65 63 74 6c 79 20 2a 2f |gn indir|ectly */|
|000013a0| 0d 00 00 06 00 00 09 00 | 00 16 00 13 09 09 66 6f |........|......fo|
|000013b0| 6f 28 26 78 2c 20 26 79 | 2c 20 26 7a 29 3b 0d 00 |o(&x, &y|, &z);..|
|000013c0| 00 06 00 00 09 00 00 16 | 00 44 09 09 66 70 72 69 |........|.D..fpri|
|000013d0| 6e 74 66 28 73 74 64 65 | 72 72 2c 20 22 45 78 61 |ntf(stde|rr, "Exa|
|000013e0| 6d 70 6c 65 20 32 3a 20 | 42 75 67 32 20 41 66 74 |mple 2: |Bug2 Aft|
|000013f0| 65 72 3a 20 20 25 67 2c | 20 25 67 2c 20 25 67 5c |er: %g,| %g, %g\|
|00001400| 6e 22 2c 20 78 2c 20 79 | 2c 20 7a 29 3b 0d 00 06 |n", x, y|, z);...|
|00001410| 00 00 09 00 00 16 00 03 | 09 7d 0d 00 00 06 00 00 |........|.}......|
|00001420| 09 00 00 16 00 12 01 e6 | 03 0a 00 00 00 12 00 31 |........|.......1|
|00001430| 00 5a 00 82 00 a6 00 cf | 00 f7 01 20 01 48 01 71 |.Z......|... .H.q|
|00001440| 01 99 02 26 02 26 00 0a | 09 09 45 4e 44 50 52 4f |...&.&..|..ENDPRO|
|00001450| 43 0d 00 06 00 00 09 00 | 00 16 ff 96 00 0e 09 66 |C.......|.......f|
|00001460| 6f 6f 28 78 2c 20 79 2c | 20 7a 29 0d 00 06 00 00 |oo(x, y,| z).....|
|00001470| 09 00 00 16 00 13 09 09 | 72 65 61 6c 20 2a 78 2c |........|real *x,|
|00001480| 20 2a 79 2c 20 2a 7a 3b | 0d 00 00 06 00 00 09 00 | *y, *z;|........|
|00001490| 00 16 00 03 09 7b 0d 00 | 00 06 00 00 09 00 00 16 |.....{..|........|
|000014a0| 00 46 09 09 66 70 72 69 | 6e 74 66 28 73 74 64 65 |.F..fpri|ntf(stde|
|000014b0| 72 72 2c 20 22 45 78 61 | 6d 70 6c 65 20 32 3a 20 |rr, "Exa|mple 2: |
|000014c0| 66 6f 6f 20 42 65 66 6f | 72 65 3a 20 25 67 2c 20 |foo Befo|re: %g, |
|000014d0| 25 67 2c 20 25 67 5c 6e | 22 2c 20 2a 78 2c 20 2a |%g, %g\n|", *x, *|
|000014e0| 79 2c 20 2a 7a 29 3b 0d | 00 06 00 00 09 00 00 16 |y, *z);.|........|
|000014f0| 00 0d 09 09 2a 78 20 3d | 20 31 31 2e 30 3b 0d 00 |....*x =| 11.0;..|
|00001500| 00 06 00 00 09 00 00 16 | 00 0d 09 09 2a 79 20 3d |........|....*y =|
|00001510| 20 31 32 2e 30 3b 0d 00 | 00 06 00 00 09 00 00 16 | 12.0;..|........|
|00001520| 00 0d 09 09 2a 7a 20 3d | 20 31 33 2e 30 3b 0d 00 |....*z =| 13.0;..|
|00001530| 00 06 00 00 09 00 00 16 | 00 46 09 09 66 70 72 69 |........|.F..fpri|
|00001540| 6e 74 66 28 73 74 64 65 | 72 72 2c 20 22 45 78 61 |ntf(stde|rr, "Exa|
|00001550| 6d 70 6c 65 20 32 3a 20 | 66 6f 6f 20 41 66 74 65 |mple 2: |foo Afte|
|00001560| 72 3a 20 20 25 67 2c 20 | 25 67 2c 20 25 67 5c 6e |r: %g, |%g, %g\n|
|00001570| 22 2c 20 2a 78 2c 20 2a | 79 2c 20 2a 7a 29 3b 0d |", *x, *|y, *z);.|
|00001580| 00 06 00 00 09 00 00 16 | 00 03 09 7d 0d 00 00 06 |........|...}....|
|00001590| 00 00 09 00 00 16 00 12 | 01 e6 03 0a 00 00 00 12 |........|........|
|000015a0| 00 31 00 5a 00 82 00 a6 | 00 cf 00 f7 01 20 01 48 |.1.Z....|..... .H|
|000015b0| 01 71 01 99 02 26 02 26 | 00 01 0d 00 00 06 00 00 |.q...&.&|........|
|000015c0| 0c 00 00 15 03 f6 09 54 | 68 69 73 20 69 73 2c 20 |.......T|his is, |
|000015d0| 69 6e 20 66 61 63 74 2c | 20 61 20 67 65 6e 65 72 |in fact,| a gener|
|000015e0| 61 6c 20 70 72 6f 62 6c | 65 6d 20 77 69 74 68 20 |al probl|em with |
|000015f0| 43 20 63 6f 6d 70 69 6c | 65 72 73 2e 20 20 54 68 |C compil|ers. Th|
|00001600| 65 20 75 6e 64 65 72 6c | 79 69 6e 67 20 72 65 61 |e underl|ying rea|
|00001610| 73 6f 6e 20 66 6f 72 20 | 74 68 69 73 20 70 72 6f |son for |this pro|
|00001620| 62 6c 65 6d 20 69 73 20 | 72 65 6c 61 74 65 64 20 |blem is |related |
|00001630| 74 6f 20 74 68 65 20 61 | 75 74 6f 6d 61 74 69 63 |to the a|utomatic|
|00001640| 20 77 69 64 65 6e 69 6e | 67 20 61 6e 64 20 6e 61 | widenin|g and na|
|00001650| 72 72 6f 77 69 6e 67 20 | 6f 66 20 62 61 73 69 63 |rrowing |of basic|
|00001660| 20 74 79 70 65 73 20 70 | 65 72 66 6f 72 6d 65 64 | types p|erformed|
|00001670| 20 62 79 20 43 20 63 6f | 6d 70 69 6c 65 72 73 2e | by C co|mpilers.|
|00001680| 20 46 6f 72 20 69 6e 73 | 74 61 6e 63 65 20 69 6e | For ins|tance in|
|00001690| 20 43 2c 20 61 73 20 64 | 65 66 69 6e 65 64 20 62 | C, as d|efined b|
|000016a0| 79 20 4b 26 52 20 28 54 | 68 65 20 43 20 50 72 6f |y K&R (T|he C Pro|
|000016b0| 67 72 61 6d 6d 69 6e 67 | 20 4c 61 6e 67 75 61 67 |gramming| Languag|
|000016c0| 65 2c 20 4b 65 72 6e 69 | 67 68 61 6e 20 26 20 52 |e, Kerni|ghan & R|
|000016d0| 69 74 63 68 69 65 2c 20 | 31 39 37 38 2c 20 41 70 |itchie, |1978, Ap|
|000016e0| 70 65 6e 64 69 78 20 41 | 20 53 65 63 2e 20 37 2e |pendix A| Sec. 7.|
|000016f0| 31 2c 20 70 31 38 36 20 | 61 6e 64 20 53 65 63 2e |1, p186 |and Sec.|
|00001700| 20 31 30 2e 31 2c 20 70 | 32 30 36 29 2c 20 76 61 | 10.1, p|206), va|
|00001710| 72 69 61 62 6c 65 73 20 | 6f 66 20 74 79 70 65 20 |riables |of type |
|00001720| 63 68 61 72 20 61 6e 64 | 20 73 68 6f 72 74 20 61 |char and| short a|
|00001730| 72 65 20 77 69 64 65 6e | 65 64 20 74 6f 20 69 6e |re widen|ed to in|
|00001740| 74 20 62 65 66 6f 72 65 | 20 62 65 69 6e 67 20 70 |t before| being p|
|00001750| 61 73 73 65 64 20 61 73 | 20 66 75 6e 63 74 69 6f |assed as| functio|
|00001760| 6e 20 61 72 67 75 6d 65 | 6e 74 73 20 61 6e 64 20 |n argume|nts and |
|00001770| 6e 61 72 72 6f 77 65 64 | 20 62 65 66 6f 72 65 20 |narrowed| before |
|00001780| 75 73 65 20 69 6e 73 69 | 64 65 20 74 68 65 20 66 |use insi|de the f|
|00001790| 75 6e 63 74 69 6f 6e 2e | 20 20 53 69 6d 69 6c 61 |unction.| Simila|
|000017a0| 72 6c 79 2c 20 74 68 65 | 20 66 6c 6f 61 74 69 6e |rly, the| floatin|
|000017b0| 67 20 70 6f 69 6e 74 20 | 74 79 70 65 20 66 6c 6f |g point |type flo|
|000017c0| 61 74 20 69 73 20 61 75 | 74 6f 6d 61 74 69 63 61 |at is au|tomatica|
|000017d0| 6c 6c 79 20 77 69 64 65 | 6e 65 64 20 74 6f 20 64 |lly wide|ned to d|
|000017e0| 6f 75 62 6c 65 20 62 65 | 66 6f 72 65 20 62 65 69 |ouble be|fore bei|
|000017f0| 6e 67 20 70 61 73 73 65 | 64 2e 20 20 4b 26 52 20 |ng passe|d. K&R |
|00001800| 6e 6f 74 65 73 2c 20 68 | 6f 77 65 76 65 72 2c 20 |notes, h|owever, |
|00001810| 74 68 61 74 20 d2 43 20 | 63 6f 6e 76 65 72 74 73 |that .C |converts|
|00001820| 20 61 6c 6c 20 66 6c 6f | 61 74 20 61 63 74 75 61 | all flo|at actua|
|00001830| 6c 20 70 61 72 61 6d 65 | 74 65 72 73 20 74 6f 20 |l parame|ters to |
|00001840| 64 6f 75 62 6c 65 2c 20 | 73 6f 20 66 6f 72 6d 61 |double, |so forma|
|00001850| 6c 20 70 61 72 61 6d 65 | 74 65 72 73 20 64 65 63 |l parame|ters dec|
|00001860| 6c 61 72 65 64 20 66 6c | 6f 61 74 20 68 61 76 65 |lared fl|oat have|
|00001870| 20 74 68 65 69 72 20 64 | 65 63 6c 61 72 61 74 69 | their d|eclarati|
|00001880| 6f 6e 73 20 61 64 6a 75 | 73 74 65 64 20 74 6f 20 |ons adju|sted to |
|00001890| 72 65 61 64 20 64 6f 75 | 62 6c 65 2e d3 20 20 54 |read dou|ble.. T|
|000018a0| 68 65 20 76 61 6c 75 65 | 20 6f 66 20 73 75 63 68 |he value| of such|
|000018b0| 20 61 20 66 6f 72 6d 61 | 6c 20 70 61 72 61 6d 65 | a forma|l parame|
|000018c0| 74 65 72 20 69 73 20 6e | 6f 74 20 6e 61 72 72 6f |ter is n|ot narro|
|000018d0| 77 65 64 20 74 6f 20 74 | 68 65 20 64 65 63 6c 61 |wed to t|he decla|
|000018e0| 72 65 64 20 74 79 70 65 | 20 6f 66 20 74 68 65 20 |red type| of the |
|000018f0| 70 61 72 61 6d 65 74 65 | 72 2c 20 69 6e 73 74 65 |paramete|r, inste|
|00001900| 61 64 20 74 68 65 20 64 | 65 63 6c 61 72 65 64 20 |ad the d|eclared |
|00001910| 74 79 70 65 20 69 73 20 | 61 64 6a 75 73 74 65 64 |type is |adjusted|
|00001920| 20 74 6f 20 6d 61 74 63 | 68 20 74 68 61 74 20 6f | to matc|h that o|
|00001930| 66 20 74 68 65 20 77 69 | 64 65 6e 65 64 20 76 61 |f the wi|dened va|
|00001940| 6c 75 65 2e 20 20 53 6f | 2c 20 69 6e 20 66 61 63 |lue. So|, in fac|
|00001950| 74 2c 20 74 68 65 20 73 | 61 6d 70 6c 65 20 63 6f |t, the s|ample co|
|00001960| 64 65 20 61 62 6f 76 65 | 20 77 69 6c 6c 20 66 61 |de above| will fa|
|00001970| 69 6c 20 69 66 20 72 65 | 61 6c 20 69 73 20 64 65 |il if re|al is de|
|00001980| 66 69 6e 65 64 20 61 73 | 20 66 6c 6f 61 74 2c 20 |fined as| float, |
|00001990| 65 76 65 6e 20 6f 6e 20 | 61 20 62 75 67 20 66 72 |even on |a bug fr|
|000019a0| 65 65 20 4b 26 52 20 63 | 6f 6e 66 6f 72 6d 69 6e |ee K&R c|onformin|
|000019b0| 67 20 63 6f 6d 70 69 6c | 65 72 2e 0d 00 d2 00 00 |g compil|er......|
|000019c0| 0c 00 00 15 00 7b 0c 04 | 00 15 00 83 0c 00 00 15 |.....{..|........|
|000019d0| 00 88 0c 04 00 15 00 91 | 0c 00 00 15 00 e1 0c 02 |........|........|
|000019e0| 00 15 00 fb 0c 00 00 15 | 01 5a 0c 00 00 16 01 5e |........|.Z.....^|
|000019f0| 0c 00 00 15 01 63 0c 00 | 00 16 01 68 0c 00 00 15 |.....c..|...h....|
|00001a00| 01 78 0c 00 00 16 01 7b | 0c 00 00 15 01 f7 0c 00 |.x.....{|........|
|00001a10| 00 16 01 fc 0c 00 00 15 | 02 19 0c 00 00 16 02 1f |........|........|
|00001a20| 0c 00 00 15 02 5f 0c 00 | 00 16 02 64 0c 00 00 15 |....._..|...d....|
|00001a30| 02 7a 0c 00 00 16 02 80 | 0c 00 00 15 02 a0 0c 00 |.z......|........|
|00001a40| 00 16 02 a5 0c 00 00 15 | 02 be 0c 04 00 15 02 c6 |........|........|
|00001a50| 0c 00 00 15 02 cf 0c 00 | 00 16 02 d5 0c 00 00 15 |........|........|
|00001a60| 03 01 0c 01 00 15 03 04 | 0c 00 00 15 03 52 0c 01 |........|.....R..|
|00001a70| 00 15 03 5a 0c 00 00 15 | 03 b0 0c 00 00 16 03 b4 |...Z....|........|
|00001a80| 0c 00 00 15 03 c3 0c 00 | 00 16 03 c8 0c 00 00 15 |........|........|
|00001a90| 00 01 0d 00 00 06 00 00 | 0c 00 00 15 01 5e 09 49 |........|.....^.I|
|00001aa0| 6e 20 4d 50 57 20 43 2c | 20 77 68 65 72 65 20 66 |n MPW C,| where f|
|00001ab0| 6c 6f 61 74 20 61 6e 64 | 20 64 6f 75 62 6c 65 20 |loat and| double |
|00001ac0| 61 72 65 20 77 69 64 65 | 6e 65 64 20 74 6f 20 65 |are wide|ned to e|
|00001ad0| 78 74 65 6e 64 65 64 2c | 20 74 68 65 20 73 61 6d |xtended,| the sam|
|00001ae0| 70 6c 65 20 63 6f 64 65 | 20 66 61 69 6c 73 20 66 |ple code| fails f|
|00001af0| 6f 72 20 65 69 74 68 65 | 72 20 66 6c 6f 61 74 20 |or eithe|r float |
|00001b00| 6f 72 20 64 6f 75 62 6c | 65 20 66 6f 72 6d 61 6c |or doubl|e formal|
|00001b10| 20 70 61 72 61 6d 65 74 | 65 72 73 2e 20 20 54 68 | paramet|ers. Th|
|00001b20| 69 73 20 63 61 6e 2c 20 | 6f 66 20 63 6f 75 72 73 |is can, |of cours|
|00001b30| 65 2c 20 6c 65 61 64 20 | 74 6f 20 61 64 64 69 74 |e, lead |to addit|
|00001b40| 69 6f 6e 61 6c 20 70 72 | 6f 62 6c 65 6d 73 20 69 |ional pr|oblems i|
|00001b50| 66 20 79 6f 75 20 61 72 | 65 20 70 6f 72 74 69 6e |f you ar|e portin|
|00001b60| 67 20 63 6f 64 65 20 66 | 72 6f 6d 20 61 6e 20 65 |g code f|rom an e|
|00001b70| 6e 76 69 72 6f 6e 6d 65 | 6e 74 20 77 68 65 72 65 |nvironme|nt where|
|00001b80| 20 64 6f 75 62 6c 65 20 | 77 61 73 20 74 68 65 20 | double |was the |
|00001b90| 77 69 64 65 6e 65 64 20 | 66 6c 6f 61 74 69 6e 67 |widened |floating|
|00001ba0| 20 70 6f 69 6e 74 20 74 | 79 70 65 20 28 77 68 65 | point t|ype (whe|
|00001bb0| 72 65 20 74 61 6b 69 6e | 67 20 74 68 65 20 61 64 |re takin|g the ad|
|00001bc0| 64 72 65 73 73 20 6f 66 | 20 61 20 64 6f 75 62 6c |dress of| a doubl|
|00001bd0| 65 20 66 6f 72 6d 61 6c | 20 70 61 72 61 6d 65 74 |e formal| paramet|
|00001be0| 65 72 20 77 6f 75 6c 64 | 20 77 6f 72 6b 20 61 73 |er would| work as|
|00001bf0| 20 65 78 70 65 63 74 65 | 64 29 2e 0d 00 4e 00 00 | expecte|d)...N..|
|00001c00| 0c 00 00 15 00 11 0c 00 | 00 16 00 16 0c 00 00 15 |........|........|
|00001c10| 00 1b 0c 00 00 16 00 21 | 0c 00 00 15 00 31 0c 00 |.......!|.....1..|
|00001c20| 00 16 00 39 0c 00 00 15 | 00 5c 0c 00 00 16 00 61 |...9....|.\.....a|
|00001c30| 0c 00 00 15 00 65 0c 00 | 00 16 00 6b 0c 00 00 15 |.....e..|...k....|
|00001c40| 00 e3 0c 00 00 16 00 e9 | 0c 00 00 15 00 01 0d 00 |........|........|
|00001c50| 00 06 00 00 0c 00 00 15 | 01 38 09 57 6f 72 6b 61 |........|.8.Worka|
|00001c60| 72 6f 75 6e 64 3a 20 20 | 54 61 6b 69 6e 67 20 74 |round: |Taking t|
|00001c70| 68 65 20 61 64 64 72 65 | 73 73 20 6f 66 20 61 20 |he addre|ss of a |
|00001c80| 66 75 6e 63 74 69 6f 6e | 20 61 72 67 75 6d 65 6e |function| argumen|
|00001c90| 74 20 69 73 20 6e 6f 74 | 20 72 65 63 6f 6d 6d 65 |t is not| recomme|
|00001ca0| 6e 64 65 64 3b 20 79 6f | 75 20 73 68 6f 75 6c 64 |nded; yo|u should|
|00001cb0| 20 6d 61 6b 65 20 61 20 | 6c 6f 63 61 6c 20 63 6f | make a |local co|
|00001cc0| 70 79 20 69 6e 20 61 20 | 74 65 6d 70 6f 72 61 72 |py in a |temporar|
|00001cd0| 79 20 76 61 72 69 61 62 | 6c 65 20 61 6e 64 20 74 |y variab|le and t|
|00001ce0| 61 6b 65 20 74 68 65 20 | 61 64 64 72 65 73 73 20 |ake the |address |
|00001cf0| 6f 66 20 74 68 65 20 63 | 6f 70 79 2e 20 49 66 20 |of the c|opy. If |
|00001d00| 79 6f 75 20 6d 75 73 74 | 20 74 61 6b 65 20 74 68 |you must| take th|
|00001d10| 65 20 61 64 64 72 65 73 | 73 20 6f 66 20 61 20 66 |e addres|s of a f|
|00001d20| 6c 6f 61 74 69 6e 67 20 | 70 6f 69 6e 74 20 66 75 |loating |point fu|
|00001d30| 6e 63 74 69 6f 6e 20 61 | 72 67 75 6d 65 6e 74 2c |nction a|rgument,|
|00001d40| 20 6d 61 6b 65 20 73 75 | 72 65 20 69 74 20 69 73 | make su|re it is|
|00001d50| 20 64 65 63 6c 61 72 65 | 64 20 61 73 20 74 79 70 | declare|d as typ|
|00001d60| 65 20 65 78 74 65 6e 64 | 65 64 2c 20 61 6e 64 20 |e extend|ed, and |
|00001d70| 74 68 65 20 70 6f 69 6e | 74 65 72 20 69 73 20 6f |the poin|ter is o|
|00001d80| 66 20 74 79 70 65 20 65 | 78 74 65 6e 64 65 64 2a |f type e|xtended*|
|00001d90| 2e 0d 00 24 00 00 0c 01 | 00 15 00 0c 0c 00 00 15 |...$....|........|
|00001da0| 01 08 0c 00 00 16 01 10 | 0c 00 00 15 01 2d 0c 00 |........|.....-..|
|00001db0| 00 16 01 36 0c 00 00 15 | 00 01 0d 00 00 06 00 00 |...6....|........|
|00001dc0| 0c 00 00 15 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |........|........|
|00001dd0| 01 4d 33 29 09 54 68 65 | 20 73 68 69 66 74 20 6f |.M3).The| shift o|
|00001de0| 70 65 72 61 74 6f 72 73 | 20 3e 3e 20 61 6e 64 20 |perators| >> and |
|00001df0| 3c 3c 20 63 61 6e 20 73 | 6f 6d 65 74 69 6d 65 73 |<< can s|ometimes|
|00001e00| 20 70 72 6f 64 75 63 65 | 20 75 6e 65 78 70 65 63 | produce| unexpec|
|00001e10| 74 65 64 20 72 65 73 75 | 6c 74 73 20 77 68 65 6e |ted resu|lts when|
|00001e20| 20 61 70 70 6c 69 65 64 | 20 74 6f 20 75 6e 73 69 | applied| to unsi|
|00001e30| 67 6e 65 64 20 73 68 6f | 72 74 20 61 6e 64 20 75 |gned sho|rt and u|
|00001e40| 6e 73 69 67 6e 65 64 20 | 63 68 61 72 20 6f 70 65 |nsigned |char ope|
|00001e50| 72 61 6e 64 73 2e 20 20 | 54 68 65 20 61 6e 6f 6d |rands. |The anom|
|00001e60| 61 6c 79 20 6c 69 65 73 | 20 69 6e 20 74 68 65 20 |aly lies| in the |
|00001e70| 66 61 63 74 20 74 68 61 | 74 20 74 68 65 20 36 38 |fact tha|t the 68|
|00001e80| 30 78 30 20 4c 53 52 2e | 4c 20 61 6e 64 20 4c 53 |0x0 LSR.|L and LS|
|00001e90| 4c 2e 4c 20 69 6e 73 74 | 72 75 63 74 69 6f 6e 73 |L.L inst|ructions|
|00001ea0| 20 61 72 65 20 75 73 65 | 64 20 69 6e 73 74 65 61 | are use|d instea|
|00001eb0| 64 20 6f 66 20 74 68 65 | 20 4c 53 52 2e 57 20 61 |d of the| LSR.W a|
|00001ec0| 6e 64 20 4c 53 4c 2e 57 | 20 6f 72 20 74 68 65 20 |nd LSL.W| or the |
|00001ed0| 4c 53 52 2e 42 20 61 6e | 64 20 4c 53 4c 2e 42 20 |LSR.B an|d LSL.B |
|00001ee0| 69 6e 73 74 72 75 63 74 | 69 6f 6e 73 2e 20 20 54 |instruct|ions. T|
|00001ef0| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 65 78 61 |he follo|wing exa|
|00001f00| 6d 70 6c 65 20 69 6c 6c | 75 73 74 72 61 74 65 73 |mple ill|ustrates|
|00001f10| 20 74 68 69 73 20 61 6e | 6f 6d 61 6c 79 3a 0d 00 | this an|omaly:..|
|00001f20| 00 66 00 00 0c 00 00 15 | 00 17 0c 00 00 16 00 19 |.f......|........|
|00001f30| 0c 00 00 15 00 1e 0c 00 | 00 16 00 20 0c 00 00 15 |........|... ....|
|00001f40| 00 b2 0c 00 00 16 00 b7 | 0c 00 00 15 00 bc 0c 00 |........|........|
|00001f50| 00 16 00 c1 0c 00 00 15 | 00 e7 0c 00 00 16 00 ec |........|........|
|00001f60| 0c 00 00 15 00 f1 0c 00 | 00 16 00 f6 0c 00 00 15 |........|........|
|00001f70| 00 fe 0c 00 00 16 01 03 | 0c 00 00 15 01 08 0c 00 |........|........|
|00001f80| 00 16 01 0d 0c 00 00 15 | 00 01 0d 00 00 06 00 00 |........|........|
|00001f90| 0a 00 00 15 00 24 01 e6 | 03 0a 00 00 00 12 00 31 |.....$..|.......1|
|00001fa0| 00 5a 00 82 00 a6 00 cf | 00 f7 01 20 01 48 01 71 |.Z......|... .H.q|
|00001fb0| 01 99 02 26 02 26 00 08 | 09 6d 61 69 6e 28 29 0d |...&.&..|.main().|
|00001fc0| 00 06 00 00 0a 00 00 16 | 00 03 09 7b 0d 00 00 06 |........|...{....|
|00001fd0| 00 00 0a 00 00 16 00 17 | 09 09 75 6e 73 69 67 6e |........|..unsign|
|00001fe0| 65 64 20 73 68 6f 72 74 | 20 75 2c 20 63 3b 0d 00 |ed short| u, c;..|
|00001ff0| 00 06 00 00 0a 00 00 16 | 00 0e 09 09 73 68 6f 72 |........|....shor|
|00002000| 74 20 69 2c 20 6b 3b 0d | 00 06 00 00 0a 00 00 16 |t i, k;.|........|
|00002010| 00 03 09 09 0d 00 00 06 | 00 00 0a 00 00 16 00 0e |........|........|
|00002020| 09 09 75 20 3d 20 30 78 | 46 46 46 46 3b 0d 00 06 |..u = 0x|FFFF;...|
|00002030| 00 00 0a 00 00 16 00 09 | 09 09 6b 20 3d 20 38 3b |........|..k = 8;|
|00002040| 0d 00 00 06 00 00 0a 00 | 00 16 00 03 09 09 0d 00 |........|........|
|00002050| 00 06 00 00 0a 00 00 16 | 00 14 09 09 69 20 3d 20 |........|....i = |
|00002060| 28 75 20 3c 3c 20 6b 29 | 2f 32 35 36 3b 0d 00 06 |(u << k)|/256;...|
|00002070| 00 00 0a 00 00 16 00 31 | 09 09 70 72 69 6e 74 66 |.......1|..printf|
|00002080| 28 22 75 6e 73 69 67 6e | 65 64 20 73 68 6f 72 74 |("unsign|ed short|
|00002090| 3a 20 69 20 3d 20 25 64 | 2c 20 25 23 78 5c 6e 22 |: i = %d|, %#x\n"|
|000020a0| 2c 20 69 2c 20 69 29 3b | 0d 00 00 06 00 00 0a 00 |, i, i);|........|
|000020b0| 00 16 00 02 09 0d 00 06 | 00 00 0a 00 00 16 00 0b |........|........|
|000020c0| 09 09 63 20 3d 20 32 35 | 36 3b 0d 00 00 06 00 00 |..c = 25|6;......|
|000020d0| 0a 00 00 16 00 12 09 09 | 69 20 3d 20 28 75 20 3c |........|i = (u <|
|000020e0| 3c 20 6b 29 2f 63 3b 0d | 00 06 00 00 0a 00 00 16 |< k)/c;.|........|
|000020f0| 00 31 09 09 70 72 69 6e | 74 66 28 22 75 6e 73 69 |.1..prin|tf("unsi|
|00002100| 67 6e 65 64 20 73 68 6f | 72 74 3a 20 69 20 3d 20 |gned sho|rt: i = |
|00002110| 25 64 2c 20 25 23 78 5c | 6e 22 2c 20 69 2c 20 69 |%d, %#x\|n", i, i|
|00002120| 29 3b 0d 00 00 06 00 00 | 0a 00 00 16 00 03 09 7d |);......|.......}|
|00002130| 0d 00 00 06 00 00 0a 00 | 00 16 00 12 01 e6 03 0a |........|........|
|00002140| 00 00 00 12 00 31 00 5a | 00 82 00 a6 00 cf 00 f7 |.....1.Z|........|
|00002150| 01 20 01 48 01 71 01 99 | 02 26 02 26 00 01 0d 00 |. .H.q..|.&.&....|
|00002160| 00 06 00 00 0c 00 00 15 | 00 be 09 54 68 69 73 20 |........|...This |
|00002170| 63 6f 64 65 20 66 72 61 | 67 6d 65 6e 74 20 72 65 |code fra|gment re|
|00002180| 74 75 72 6e 73 20 74 68 | 65 20 76 61 6c 75 65 73 |turns th|e values|
|00002190| 20 2d 31 2c 20 30 78 46 | 46 46 46 46 46 46 46 20 | -1, 0xF|FFFFFFF |
|000021a0| 61 6e 64 20 2d 31 2c 20 | 30 78 46 46 46 46 46 46 |and -1, |0xFFFFFF|
|000021b0| 46 46 2c 20 77 68 69 63 | 68 20 61 72 65 20 74 68 |FF, whic|h are th|
|000021c0| 65 20 63 6f 72 72 65 63 | 74 20 76 61 6c 75 65 73 |e correc|t values|
|000021d0| 20 61 73 20 64 65 66 69 | 6e 65 64 20 62 79 20 74 | as defi|ned by t|
|000021e0| 68 65 20 43 20 6c 61 6e | 67 75 61 67 65 2c 20 68 |he C lan|guage, h|
|000021f0| 6f 77 65 76 65 72 2c 20 | 79 6f 75 20 6d 69 67 68 |owever, |you migh|
|00002200| 74 20 62 65 20 65 78 70 | 65 63 74 69 6e 67 20 32 |t be exp|ecting 2|
|00002210| 35 35 2c 20 30 78 46 46 | 20 61 6e 64 20 32 35 35 |55, 0xFF| and 255|
|00002220| 2c 20 30 78 46 46 2e 0d | 00 06 00 00 0c 00 00 15 |, 0xFF..|........|
|00002230| 00 01 0d 00 00 06 00 00 | 0c 00 00 15 00 01 0d 00 |........|........|
|00002240| 00 06 00 00 0c 00 00 15 | 01 5b 34 29 09 54 68 65 |........|.[4).The|
|00002250| 20 63 6f 6d 70 69 6c 65 | 72 20 6f 70 74 69 6d 69 | compile|r optimi|
|00002260| 7a 61 74 69 6f 6e 20 66 | 6c 61 67 73 20 2d 71 20 |zation f|lags -q |
|00002270| 28 73 61 63 72 69 66 69 | 63 65 20 63 6f 64 65 20 |(sacrifi|ce code |
|00002280| 73 69 7a 65 20 66 6f 72 | 20 73 70 65 65 64 29 20 |size for| speed) |
|00002290| 61 6e 64 20 2d 71 32 20 | 28 6d 65 6d 6f 72 79 20 |and -q2 |(memory |
|000022a0| 6c 6f 63 61 74 69 6f 6e | 73 20 77 6f 6e d5 74 20 |location|s won.t |
|000022b0| 63 68 61 6e 67 65 20 65 | 78 63 65 70 74 20 62 79 |change e|xcept by|
|000022c0| 20 65 78 70 6c 69 63 69 | 74 20 73 74 6f 72 65 73 | explici|t stores|
|000022d0| 29 20 63 61 6e 20 70 72 | 6f 64 75 63 65 20 69 6e |) can pr|oduce in|
|000022e0| 63 6f 72 72 65 63 74 20 | 63 6f 64 65 2e 20 57 65 |correct |code. We|
|000022f0| 20 68 61 76 65 20 73 65 | 76 65 72 61 6c 20 76 61 | have se|veral va|
|00002300| 67 75 65 20 64 65 73 63 | 72 69 70 74 69 6f 6e 73 |gue desc|riptions|
|00002310| 20 6f 66 20 70 72 6f 62 | 6c 65 6d 73 2c 20 61 6e | of prob|lems, an|
|00002320| 64 20 61 72 65 20 6c 6f | 6f 6b 69 6e 67 20 66 6f |d are lo|oking fo|
|00002330| 72 20 6d 6f 72 65 20 73 | 70 65 63 69 66 69 63 20 |r more s|pecific |
|00002340| 65 78 61 6d 70 6c 65 73 | 2e 20 20 54 68 65 20 66 |examples|. The f|
|00002350| 6f 6c 6c 6f 77 69 6e 67 | 20 65 78 61 6d 70 6c 65 |ollowing| example|
|00002360| 20 69 6c 6c 75 73 74 72 | 61 74 65 73 20 61 20 73 | illustr|ates a s|
|00002370| 70 65 63 69 66 69 63 20 | 62 75 67 20 74 68 61 74 |pecific |bug that|
|00002380| 20 6f 63 63 75 72 73 20 | 77 68 65 6e 20 75 73 69 | occurs |when usi|
|00002390| 6e 67 20 65 6e 75 6d 65 | 72 61 74 65 64 20 74 79 |ng enume|rated ty|
|000023a0| 70 65 73 3a 0d 00 00 2a | 00 00 0c 00 00 15 00 23 |pes:...*|.......#|
|000023b0| 0c 00 00 16 00 25 0c 00 | 00 15 00 4a 0c 00 00 16 |.....%..|...J....|
|000023c0| 00 4d 0c 00 00 15 01 49 | 0c 04 00 15 01 59 0c 00 |.M.....I|.....Y..|
|000023d0| 00 15 00 01 0d 00 00 06 | 00 00 0c 00 00 15 00 24 |........|.......$|
|000023e0| 01 e6 03 0a 00 00 00 12 | 00 31 00 5a 00 82 00 a6 |........|.1.Z....|
|000023f0| 00 cf 00 f7 01 20 01 48 | 01 71 01 99 02 10 02 10 |..... .H|.q......|
|00002400| 00 12 09 62 61 64 66 75 | 6e 63 28 62 6f 6f 6c 2c |...badfu|nc(bool,|
|00002410| 20 69 29 0d 00 06 00 00 | 09 00 00 16 00 11 09 09 | i).....|........|
|00002420| 42 6f 6f 6c 65 61 6e 20 | 2a 62 6f 6f 6c 3b 0d 00 |Boolean |*bool;..|
|00002430| 00 06 00 00 09 00 00 16 | 00 09 09 09 69 6e 74 20 |........|....int |
|00002440| 69 3b 0d 00 00 06 00 00 | 09 00 00 16 00 03 09 7b |i;......|.......{|
|00002450| 0d 00 00 06 00 00 09 00 | 00 16 00 11 09 09 77 68 |........|......wh|
|00002460| 69 6c 65 20 28 74 72 75 | 65 29 20 7b 0d 00 00 06 |ile (tru|e) {....|
|00002470| 00 00 09 00 00 16 00 0f | 09 09 09 69 66 28 69 20 |........|...if(i |
|00002480| 3c 20 33 29 20 7b 0d 00 | 00 06 00 00 09 00 00 16 |< 3) {..|........|
|00002490| 00 13 09 09 09 09 2a 62 | 6f 6f 6c 20 20 3d 20 74 |......*b|ool = t|
|000024a0| 72 75 65 3b 0d 00 00 06 | 00 00 09 00 00 16 00 19 |rue;....|........|
|000024b0| 09 09 09 09 69 66 20 28 | 66 75 6e 63 28 31 29 29 |....if (|func(1))|
|000024c0| 20 72 65 74 75 72 6e 3b | 0d 00 00 06 00 00 09 00 | return;|........|
|000024d0| 00 16 00 05 09 09 09 7d | 0d 00 00 06 00 00 09 00 |.......}|........|
|000024e0| 00 16 00 19 09 09 20 09 | 69 66 20 28 66 75 6e 63 |...... .|if (func|
|000024f0| 28 69 29 29 20 72 65 74 | 75 72 6e 3b 0d 00 00 06 |(i)) ret|urn;....|
|00002500| 00 00 09 00 00 16 00 04 | 09 09 7d 0d 00 06 00 00 |........|..}.....|
|00002510| 09 00 00 16 00 03 09 7d | 0d 00 00 06 00 00 09 00 |.......}|........|
|00002520| 00 16 00 12 01 e6 03 0a | 00 00 00 12 00 31 00 5a |........|.....1.Z|
|00002530| 00 82 00 a6 00 cf 00 f7 | 01 20 01 48 01 71 01 99 |........|. .H.q..|
|00002540| 02 26 02 26 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |.&.&....|........|
|00002550| 01 57 09 54 68 65 20 65 | 6e 75 6d 65 72 61 74 65 |.W.The e|numerate|
|00002560| 64 20 74 79 70 65 20 68 | 65 72 65 20 69 73 20 74 |d type h|ere is t|
|00002570| 68 65 20 74 79 70 65 20 | 75 73 65 64 20 74 6f 20 |he type |used to |
|00002580| 64 65 66 69 6e 65 20 74 | 68 65 20 76 61 6c 75 65 |define t|he value|
|00002590| 73 20 74 72 75 65 20 61 | 6e 64 20 66 61 6c 73 65 |s true a|nd false|
|000025a0| 20 69 6e 20 74 68 65 20 | 68 65 61 64 65 72 20 66 | in the |header f|
|000025b0| 69 6c 65 20 54 79 70 65 | 73 2e 68 2e 20 20 54 68 |ile Type|s.h. Th|
|000025c0| 65 20 6f 70 74 69 6d 69 | 7a 65 72 20 69 73 20 61 |e optimi|zer is a|
|000025d0| 70 70 61 72 65 6e 74 6c | 79 20 63 6f 6e 66 75 73 |pparentl|y confus|
|000025e0| 65 64 20 62 79 20 74 68 | 65 20 66 61 63 74 20 74 |ed by th|e fact t|
|000025f0| 68 61 74 20 74 72 75 65 | 20 68 61 73 20 74 68 65 |hat true| has the|
|00002600| 20 63 68 61 72 20 76 61 | 6c 75 65 20 31 2c 20 77 | char va|lue 1, w|
|00002610| 68 69 63 68 20 69 74 20 | 74 68 69 6e 6b 73 20 69 |hich it |thinks i|
|00002620| 73 20 74 68 65 20 73 61 | 6d 65 20 61 73 20 74 68 |s the sa|me as th|
|00002630| 65 20 69 6e 74 20 76 61 | 6c 75 65 20 31 20 74 6f |e int va|lue 1 to|
|00002640| 20 62 65 20 70 61 73 73 | 65 64 20 74 6f 20 74 68 | be pass|ed to th|
|00002650| 65 20 66 75 6e 63 74 69 | 6f 6e 20 66 75 6e 63 28 |e functi|on func(|
|00002660| 29 2e 20 54 68 65 20 6f | 62 6a 65 63 74 20 63 6f |). The o|bject co|
|00002670| 64 65 20 70 72 6f 64 75 | 63 65 64 20 66 6f 72 20 |de produ|ced for |
|00002680| 74 68 65 20 74 77 6f 20 | 63 61 6c 6c 73 20 74 6f |the two |calls to|
|00002690| 20 74 68 65 20 66 75 6e | 63 74 69 6f 6e 20 66 75 | the fun|ction fu|
|000026a0| 6e 63 28 29 20 69 73 3a | 0d 00 00 72 00 00 0c 00 |nc() is:|...r....|
|000026b0| 00 15 00 40 0c 00 00 16 | 00 44 0c 00 00 15 00 49 |...@....|.D.....I|
|000026c0| 0c 00 00 16 00 4e 0c 00 | 00 15 00 62 0c 00 00 16 |.....N..|...b....|
|000026d0| 00 69 0c 00 00 15 00 a2 | 0c 00 00 16 00 a6 0c 00 |.i......|........|
|000026e0| 00 15 00 af 0c 00 00 16 | 00 b3 0c 00 00 15 00 ba |........|........|
|000026f0| 0c 00 00 16 00 bb 0c 00 | 00 15 00 e0 0c 00 00 16 |........|........|
|00002700| 00 e3 0c 00 00 15 00 ea | 0c 00 00 16 00 eb 0c 00 |........|........|
|00002710| 00 15 01 4c 0c 00 00 16 | 01 52 0c 00 00 15 00 01 |...L....|.R......|
|00002720| 0d 00 00 06 00 00 0c 00 | 00 15 00 24 01 e6 03 0a |........|...$....|
|00002730| 00 00 00 12 00 31 00 5a | 00 82 00 a6 00 cf 00 f7 |.....1.Z|........|
|00002740| 01 20 01 48 01 71 01 99 | 02 10 02 10 00 05 09 2e |. .H.q..|........|
|00002750| 2e 2e 0d 00 00 06 00 00 | 09 00 00 16 00 35 09 4d |........|.....5.M|
|00002760| 4f 56 45 51 09 23 24 30 | 31 2c 44 33 09 3b 20 4d |OVEQ.#$0|1,D3.; M|
|00002770| 6f 76 65 20 74 68 65 20 | 63 6f 6e 73 74 61 6e 74 |ove the |constant|
|00002780| 20 31 20 69 6e 74 6f 20 | 61 20 72 65 67 69 73 74 | 1 into |a regist|
|00002790| 65 72 0d 00 00 06 00 00 | 09 00 00 16 00 05 09 2e |er......|........|
|000027a0| 2e 2e 0d 00 00 06 00 00 | 09 00 00 16 00 32 09 4d |........|.....2.M|
|000027b0| 4f 56 45 2e 42 09 44 33 | 2c 28 41 32 29 20 09 3b |OVE.B.D3|,(A2) .;|
|000027c0| 20 41 73 73 69 67 6e 20 | 22 74 72 75 65 22 20 74 | Assign |"true" t|
|000027d0| 6f 20 76 61 72 69 61 62 | 6c 65 20 62 6f 6f 6c 0d |o variab|le bool.|
|000027e0| 00 06 00 00 09 00 00 16 | 00 38 09 4d 4f 56 45 2e |........|.8.MOVE.|
|000027f0| 42 09 44 33 2c 2d 28 41 | 37 29 09 3b 20 41 74 74 |B.D3,-(A|7).; Att|
|00002800| 65 6d 70 74 20 74 6f 20 | 70 75 73 68 20 69 6e 74 |empt to |push int|
|00002810| 65 67 65 72 20 31 20 6f | 6e 74 6f 20 73 74 61 63 |eger 1 o|nto stac|
|00002820| 6b 0d 00 06 00 00 09 00 | 00 16 00 22 09 09 09 3b |k.......|..."...;|
|00002830| 20 45 52 52 4f 52 20 73 | 68 6f 75 6c 64 20 62 65 | ERROR s|hould be|
|00002840| 20 4d 4f 56 45 2e 4c 20 | 21 21 21 21 21 0d 00 06 | MOVE.L |!!!!!...|
|00002850| 00 00 09 00 00 16 00 1b | 09 4a 53 52 09 2a 2b 24 |........|.JSR.*+$|
|00002860| 30 30 30 32 09 3b 20 4a | 53 52 20 74 6f 20 66 75 |0002.; J|SR to fu|
|00002870| 6e 63 0d 00 00 06 00 00 | 09 00 00 16 00 05 09 2e |nc......|........|
|00002880| 2e 2e 0d 00 00 06 00 00 | 09 00 00 16 00 41 09 4d |........|.....A.M|
|00002890| 4f 56 45 2e 4c 09 44 34 | 2c 2d 28 41 37 29 20 09 |OVE.L.D4|,-(A7) .|
|000028a0| 3b 20 43 6f 72 72 65 63 | 74 6c 79 20 70 75 73 68 |; Correc|tly push|
|000028b0| 20 69 6e 74 65 67 65 72 | 20 76 61 72 69 61 62 6c | integer| variabl|
|000028c0| 65 20 69 20 6f 6e 74 6f | 20 73 74 61 63 6b 0d ff |e i onto| stack..|
|000028d0| 00 06 00 00 09 00 00 16 | 00 1c 09 4a 53 52 09 2a |........|...JSR.*|
|000028e0| 2b 24 30 30 30 32 20 09 | 3b 20 4a 53 52 20 74 6f |+$0002 .|; JSR to|
|000028f0| 20 66 75 6e 63 0d 00 06 | 00 00 09 00 00 16 00 05 | func...|........|
|00002900| 09 2e 2e 2e 0d ff 00 06 | 00 00 09 00 00 16 00 12 |........|........|
|00002910| 01 e6 03 08 00 00 00 12 | 00 31 00 6c 00 cf 00 f7 |........|.1.l....|
|00002920| 01 20 01 48 01 71 01 99 | 02 26 02 26 00 00 00 00 |. .H.q..|.&.&....|
|00002930| 00 01 0d ff 00 06 00 00 | 0c 00 00 15 01 b4 09 49 |........|.......I|
|00002940| 6e 20 74 68 65 20 66 69 | 72 73 74 20 66 75 6e 63 |n the fi|rst func|
|00002950| 74 69 6f 6e 20 63 61 6c | 6c 2c 20 74 68 65 20 69 |tion cal|l, the i|
|00002960| 6e 74 20 63 6f 6e 73 74 | 61 6e 74 20 31 20 69 73 |nt const|ant 1 is|
|00002970| 20 70 61 73 73 65 64 20 | 61 73 20 61 20 62 79 74 | passed |as a byt|
|00002980| 65 20 76 61 6c 75 65 21 | 20 53 69 6e 63 65 20 74 |e value!| Since t|
|00002990| 68 65 20 73 74 61 63 6b | 20 69 73 20 63 6f 72 72 |he stack| is corr|
|000029a0| 65 63 74 6c 79 20 61 64 | 6a 75 73 74 65 64 20 61 |ectly ad|justed a|
|000029b0| 66 74 65 72 20 74 68 65 | 20 66 69 72 73 74 20 63 |fter the| first c|
|000029c0| 61 6c 6c 20 74 68 69 73 | 20 65 72 72 6f 72 20 6d |all this| error m|
|000029d0| 61 79 20 67 6f 20 75 6e | 64 65 74 65 63 74 65 64 |ay go un|detected|
|000029e0| 20 28 65 78 63 65 70 74 | 20 74 68 61 74 20 74 68 | (except| that th|
|000029f0| 65 20 63 61 6c 6c 65 64 | 20 66 75 6e 63 74 69 6f |e called| functio|
|00002a00| 6e 20 6d 61 79 20 73 70 | 6f 74 20 74 68 65 20 72 |n may sp|ot the r|
|00002a10| 65 73 75 6c 74 69 6e 67 | 20 6e 6f 6e 73 65 6e 73 |esulting| nonsens|
|00002a20| 69 63 61 6c 20 70 61 72 | 61 6d 65 74 65 72 29 2e |ical par|ameter).|
|00002a30| 20 20 54 68 69 73 20 70 | 72 6f 62 6c 65 6d 20 69 | This p|roblem i|
|00002a40| 73 2c 20 6f 66 20 63 6f | 75 72 73 65 2c 20 6e 6f |s, of co|urse, no|
|00002a50| 74 20 6c 69 6d 69 74 65 | 64 20 74 6f 20 74 68 65 |t limite|d to the|
|00002a60| 20 65 6e 75 6d 65 72 61 | 74 65 64 20 74 79 70 65 | enumera|ted type|
|00002a70| 20 64 65 66 69 6e 69 6e | 67 20 74 72 75 65 20 61 | definin|g true a|
|00002a80| 6e 64 20 66 61 6c 73 65 | 2c 20 62 75 74 20 63 61 |nd false|, but ca|
|00002a90| 6e 20 6f 63 63 75 72 20 | 61 73 20 61 20 73 69 64 |n occur |as a sid|
|00002aa0| 65 20 65 66 66 65 63 74 | 20 6f 66 20 61 6e 79 20 |e effect| of any |
|00002ab0| 6f 66 20 74 68 65 20 6d | 61 6e 79 20 65 6e 75 6d |of the m|any enum|
|00002ac0| 65 72 61 74 65 64 20 74 | 79 70 65 73 20 64 65 66 |erated t|ypes def|
|00002ad0| 69 6e 65 64 20 69 6e 20 | 74 68 65 20 54 6f 6f 6c |ined in |the Tool|
|00002ae0| 62 6f 78 20 68 65 61 64 | 65 72 20 66 69 6c 65 73 |box head|er files|
|00002af0| 2e 0d 00 36 00 00 0c 00 | 00 15 00 21 0c 00 00 16 |...6....|...!....|
|00002b00| 00 24 0c 00 00 15 00 2e | 0c 00 00 16 00 2f 0c 00 |.$......|...../..|
|00002b10| 00 15 01 3c 0c 00 00 16 | 01 40 0c 00 00 15 01 45 |...<....|.@.....E|
|00002b20| 0c 00 00 16 01 4a 0c 00 | 00 15 00 01 0d 00 00 06 |.....J..|........|
|00002b30| 00 00 0c 00 00 15 00 6a | 09 57 6f 72 6b 61 72 6f |.......j|.Workaro|
|00002b40| 75 6e 64 3a 20 20 54 68 | 65 20 62 65 73 74 20 73 |und: Th|e best s|
|00002b50| 6f 6c 75 74 69 6f 6e 2c | 20 66 6f 72 20 6e 6f 77 |olution,| for now|
|00002b60| 2c 20 69 73 20 74 6f 20 | 61 76 6f 69 64 20 75 73 |, is to |avoid us|
|00002b70| 69 6e 67 20 74 68 65 20 | 6f 70 74 69 6d 69 7a 61 |ing the |optimiza|
|00002b80| 74 69 6f 6e 20 66 6c 61 | 67 73 20 2d 71 20 61 6e |tion fla|gs -q an|
|00002b90| 64 20 2d 71 32 20 61 6c | 74 6f 67 65 74 68 65 72 |d -q2 al|together|
|00002ba0| 2e 0d 00 24 00 00 0c 01 | 00 15 00 0c 0c 00 00 15 |...$....|........|
|00002bb0| 00 53 0c 00 00 16 00 55 | 0c 00 00 15 00 5a 0c 00 |.S.....U|.....Z..|
|00002bc0| 00 16 00 5d 0c 00 00 15 | 00 01 0d 00 00 06 00 00 |...]....|........|
|00002bd0| 0c 00 00 15 01 d4 35 29 | 09 54 68 65 20 63 6f 6d |......5)|.The com|
|00002be0| 70 69 6c 65 72 20 66 6c | 61 67 20 2d 6d 63 36 38 |piler fl|ag -mc68|
|00002bf0| 30 32 30 20 28 67 65 6e | 65 72 61 74 65 20 4d 43 |020 (gen|erate MC|
|00002c00| 36 38 30 32 30 20 69 6e | 73 74 72 75 63 74 69 6f |68020 in|structio|
|00002c10| 6e 73 29 20 67 65 6e 65 | 72 61 74 65 73 20 69 6e |ns) gene|rates in|
|00002c20| 63 6f 6e 73 69 73 74 65 | 6e 74 20 63 6f 64 65 20 |consiste|nt code |
|00002c30| 77 68 65 6e 20 70 61 73 | 73 69 6e 67 20 73 74 72 |when pas|sing str|
|00002c40| 75 63 74 75 72 65 73 20 | 62 79 20 76 61 6c 75 65 |uctures |by value|
|00002c50| 2e 20 20 53 70 65 63 69 | 66 69 63 61 6c 6c 79 2c |. Speci|fically,|
|00002c60| 20 73 74 72 75 63 74 75 | 72 65 73 20 6c 61 72 67 | structu|res larg|
|00002c70| 65 72 20 74 68 61 6e 20 | 34 20 62 79 74 65 73 20 |er than |4 bytes |
|00002c80| 74 68 61 74 20 61 72 65 | 20 6e 6f 74 20 61 20 6d |that are| not a m|
|00002c90| 75 6c 74 69 70 6c 65 20 | 6f 66 20 34 20 62 79 74 |ultiple |of 4 byt|
|00002ca0| 65 73 20 61 72 65 20 70 | 61 64 64 65 64 20 6f 75 |es are p|added ou|
|00002cb0| 74 20 74 6f 20 74 68 65 | 20 6e 65 61 72 65 73 74 |t to the| nearest|
|00002cc0| 20 34 20 62 79 74 65 20 | 6d 75 6c 74 69 70 6c 65 | 4 byte |multiple|
|00002cd0| 20 62 65 66 6f 72 65 20 | 62 65 69 6e 67 20 70 75 | before |being pu|
|00002ce0| 73 68 65 64 20 6f 6e 74 | 6f 20 74 68 65 20 73 74 |shed ont|o the st|
|00002cf0| 61 63 6b 20 62 79 20 74 | 68 65 20 63 61 6c 6c 69 |ack by t|he calli|
|00002d00| 6e 67 20 72 6f 75 74 69 | 6e 65 2e 20 20 55 6e 66 |ng routi|ne. Unf|
|00002d10| 6f 72 74 75 6e 61 74 65 | 6c 79 2c 20 74 68 65 20 |ortunate|ly, the |
|00002d20| 63 61 6c 6c 65 64 20 72 | 6f 75 74 69 6e 65 20 64 |called r|outine d|
|00002d30| 6f 65 73 20 6e 6f 74 20 | 74 61 6b 65 20 74 68 69 |oes not |take thi|
|00002d40| 73 20 70 61 64 64 69 6e | 67 20 69 6e 74 6f 20 61 |s paddin|g into a|
|00002d50| 63 63 6f 75 6e 74 20 77 | 68 65 6e 20 61 63 63 65 |ccount w|hen acce|
|00002d60| 73 73 69 6e 67 20 69 74 | 73 20 66 75 6e 63 74 69 |ssing it|s functi|
|00002d70| 6f 6e 20 61 72 67 75 6d | 65 6e 74 73 2e 20 54 68 |on argum|ents. Th|
|00002d80| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 65 78 61 6d |e follow|ing exam|
|00002d90| 70 6c 65 20 69 6c 6c 75 | 73 74 72 61 74 65 73 20 |ple illu|strates |
|00002da0| 74 68 69 73 20 62 75 67 | 3a 0d 00 12 00 00 0c 00 |this bug|:.......|
|00002db0| 00 15 00 15 0c 00 00 16 | 00 1d 0c 00 00 15 00 01 |........|........|
|00002dc0| 0d ff 00 06 00 00 0c 00 | 00 15 00 24 01 e6 03 0a |........|...$....|
|00002dd0| 00 00 00 12 00 31 00 5a | 00 82 00 a6 00 cf 00 f7 |.....1.Z|........|
|00002de0| 01 20 01 48 01 71 01 99 | 02 10 02 10 00 14 09 23 |. .H.q..|.......#|
|00002df0| 69 6e 63 6c 75 64 65 20 | 3c 54 79 70 65 73 2e 68 |include |<Types.h|
|00002e00| 3e 0d 00 06 00 00 09 00 | 00 16 00 16 09 23 69 6e |>.......|.....#in|
|00002e10| 63 6c 75 64 65 20 3c 73 | 74 72 69 6e 67 73 2e 68 |clude <s|trings.h|
|00002e20| 3e 0d 00 06 00 00 09 00 | 00 16 00 02 09 0d 00 06 |>.......|........|
|00002e30| 00 00 09 00 00 16 00 34 | 09 74 79 70 65 64 65 66 |.......4|.typedef|
|00002e40| 20 73 74 72 75 63 74 20 | 20 20 20 20 20 20 20 20 | struct | |
|00002e50| 2f 2a 20 36 20 62 79 74 | 65 20 6c 6f 6e 67 20 73 |/* 6 byt|e long s|
|00002e60| 74 72 75 63 74 75 72 65 | 20 2a 2f 0d 00 06 00 00 |tructure| */.....|
|00002e70| 09 00 00 16 00 03 09 7b | 0d 00 00 06 00 00 09 00 |.......{|........|
|00002e80| 00 16 00 10 09 20 20 73 | 68 6f 72 74 20 54 65 6d |..... s|hort Tem|
|00002e90| 70 31 3b 0d 00 06 00 00 | 09 00 00 16 00 10 09 20 |p1;.....|....... |
|00002ea0| 20 73 68 6f 72 74 20 54 | 65 6d 70 32 3b 0d 00 06 | short T|emp2;...|
|00002eb0| 00 00 09 00 00 16 00 10 | 09 20 20 73 68 6f 72 74 |........|. short|
|00002ec0| 20 54 65 6d 70 33 3b 0d | 00 06 00 00 09 00 00 16 | Temp3;.|........|
|00002ed0| 00 0f 09 7d 20 54 65 73 | 74 53 74 72 75 63 74 3b |...} Tes|tStruct;|
|00002ee0| 0d 00 00 06 00 00 09 00 | 00 16 00 02 09 0d 00 06 |........|........|
|00002ef0| 00 00 09 00 00 16 00 08 | 09 6d 61 69 6e 28 29 0d |........|.main().|
|00002f00| 00 06 00 00 09 00 00 16 | 00 03 09 7b 0d 00 00 06 |........|...{....|
|00002f10| 00 00 09 00 00 16 00 15 | 09 20 20 54 65 73 74 53 |........|. TestS|
|00002f20| 74 72 75 63 74 20 72 65 | 70 6c 79 3b 0d 00 00 06 |truct re|ply;....|
|00002f30| 00 00 09 00 00 16 00 02 | 09 0d 00 06 00 00 09 00 |........|........|
|00002f40| 00 16 00 20 09 20 20 66 | 6f 6f 28 72 65 70 6c 79 |... . f|oo(reply|
|00002f50| 2c 22 48 65 6c 6c 6f 20 | 77 6f 72 6c 64 2e 5c 6e |,"Hello |world.\n|
|00002f60| 22 29 3b 0d 00 06 00 00 | 09 00 00 16 00 03 09 7d |");.....|.......}|
|00002f70| 0d ff 00 06 00 00 09 00 | 00 16 00 02 09 0d 00 06 |........|........|
|00002f80| 00 00 09 00 00 16 00 02 | 09 0d 00 06 00 00 09 00 |........|........|
|00002f90| 00 16 00 0f 09 66 6f 6f | 28 74 73 74 20 2c 73 74 |.....foo|(tst ,st|
|00002fa0| 72 29 0d ff 00 06 00 00 | 09 00 00 16 00 13 09 20 |r)......|....... |
|00002fb0| 20 54 65 73 74 53 74 72 | 75 63 74 20 74 73 74 3b | TestStr|uct tst;|
|00002fc0| 0d 00 00 06 00 00 09 00 | 00 16 00 0e 09 20 20 63 |........|..... c|
|00002fd0| 68 61 72 20 2a 73 74 72 | 3b 0d 00 06 00 00 09 00 |har *str|;.......|
|00002fe0| 00 16 00 03 09 7b 0d 00 | 00 06 00 00 09 00 00 16 |.....{..|........|
|00002ff0| 00 43 09 20 20 44 65 62 | 75 67 67 65 72 28 29 3b |.C. Deb|ugger();|
|00003000| 09 2f 2a 20 53 6f 20 77 | 65 20 63 61 6e 20 6c 6f |./* So w|e can lo|
|00003010| 6f 6b 2c 20 62 65 66 6f | 72 65 20 73 74 65 70 70 |ok, befo|re stepp|
|00003020| 69 6e 67 20 6f 66 66 20 | 74 68 65 20 63 6c 69 66 |ing off |the clif|
|00003030| 66 20 2a 2f 0d 00 00 06 | 00 00 09 00 00 16 00 15 |f */....|........|
|00003040| 09 20 20 70 72 69 6e 74 | 66 28 22 25 73 22 2c 73 |. print|f("%s",s|
|00003050| 74 72 29 3b 0d 00 00 06 | 00 00 09 00 00 16 00 03 |tr);....|........|
|00003060| 09 7d 0d 00 00 06 00 00 | 09 00 00 16 00 12 01 e6 |.}......|........|
|00003070| 03 0a 00 00 00 12 00 31 | 00 5a 00 82 00 a6 00 cf |.......1|.Z......|
|00003080| 00 f7 01 20 01 48 01 71 | 01 99 02 26 02 26 00 01 |... .H.q|...&.&..|
|00003090| 0d 00 00 06 00 00 0c 00 | 00 15 02 36 09 53 69 6e |........|...6.Sin|
|000030a0| 63 65 20 66 75 6e 63 74 | 69 6f 6e 20 61 72 67 75 |ce funct|ion argu|
|000030b0| 6d 65 6e 74 73 20 61 72 | 65 20 70 75 73 68 65 64 |ments ar|e pushed|
|000030c0| 20 6f 6e 74 6f 20 74 68 | 65 20 73 74 61 63 6b 20 | onto th|e stack |
|000030d0| 69 6e 20 6c 65 66 74 20 | 74 6f 20 72 69 67 68 74 |in left |to right|
|000030e0| 20 6f 72 64 65 72 20 69 | 6e 20 43 2c 20 74 68 65 | order i|n C, the|
|000030f0| 20 70 6f 69 6e 74 65 72 | 20 74 6f 20 74 68 65 20 | pointer| to the |
|00003100| 73 74 72 69 6e 67 20 63 | 6f 6e 73 74 61 6e 74 20 |string c|onstant |
|00003110| 22 48 65 6c 6c 6f 20 77 | 6f 72 6c 64 2e 5c 6e 22 |"Hello w|orld.\n"|
|00003120| 20 69 73 20 70 75 73 68 | 65 64 20 6f 6e 74 6f 20 | is push|ed onto |
|00003130| 74 68 65 20 73 74 61 63 | 6b 20 62 65 66 6f 72 65 |the stac|k before|
|00003140| 20 74 68 65 20 70 61 64 | 64 65 64 20 63 6f 6e 74 | the pad|ded cont|
|00003150| 65 6e 74 73 20 6f 66 20 | 74 68 65 20 72 65 70 6c |ents of |the repl|
|00003160| 79 20 73 74 72 75 63 74 | 75 72 65 2e 20 20 54 68 |y struct|ure. Th|
|00003170| 75 73 20 77 68 65 6e 20 | 74 68 65 20 63 61 6c 6c |us when |the call|
|00003180| 65 64 20 66 75 6e 63 74 | 69 6f 6e 2c 20 66 6f 6f |ed funct|ion, foo|
|00003190| 28 29 2c 20 67 6f 65 73 | 20 74 6f 20 66 65 74 63 |(), goes| to fetc|
|000031a0| 68 20 74 68 65 20 61 72 | 67 75 6d 65 6e 74 20 73 |h the ar|gument s|
|000031b0| 74 72 2c 20 69 74 20 6c | 6f 6f 6b 73 20 61 74 20 |tr, it l|ooks at |
|000031c0| 74 68 65 20 6c 6f 63 61 | 74 69 6f 6e 20 6a 75 73 |the loca|tion jus|
|000031d0| 74 20 62 65 79 6f 6e 64 | 20 77 68 65 72 65 20 74 |t beyond| where t|
|000031e0| 68 65 20 61 72 67 75 6d | 65 6e 74 20 74 73 74 20 |he argum|ent tst |
|000031f0| 69 73 20 6c 6f 63 61 74 | 65 64 2e 20 55 6e 66 6f |is locat|ed. Unfo|
|00003200| 72 74 75 6e 61 74 65 6c | 79 2c 20 73 69 6e 63 65 |rtunatel|y, since|
|00003210| 20 74 68 65 20 63 61 6c | 6c 65 64 20 66 75 6e 63 | the cal|led func|
|00003220| 74 69 6f 6e 20 64 6f 65 | 73 20 6e 6f 74 20 6b 6e |tion doe|s not kn|
|00003230| 6f 77 20 74 68 65 20 73 | 74 72 75 63 74 75 72 65 |ow the s|tructure|
|00003240| 20 61 72 67 75 6d 65 6e | 74 20 77 61 73 20 70 61 | argumen|t was pa|
|00003250| 64 64 65 64 2c 20 69 74 | 20 77 69 6c 6c 20 6e 6f |dded, it| will no|
|00003260| 74 20 66 69 6e 64 20 74 | 68 65 20 63 6f 72 72 65 |t find t|he corre|
|00003270| 63 74 20 76 61 6c 75 65 | 20 66 6f 72 20 74 68 65 |ct value| for the|
|00003280| 20 73 65 63 6f 6e 64 20 | 61 72 67 75 6d 65 6e 74 | second |argument|
|00003290| 20 28 6f 72 20 69 6e 20 | 74 68 65 20 67 65 6e 65 | (or in |the gene|
|000032a0| 72 61 6c 20 63 61 73 65 | 2c 20 61 6e 79 20 61 72 |ral case|, any ar|
|000032b0| 67 75 6d 65 6e 74 73 20 | 66 6f 6c 6c 6f 77 69 6e |guments |followin|
|000032c0| 67 20 74 68 65 20 73 74 | 72 75 63 74 75 72 65 29 |g the st|ructure)|
|000032d0| 2e 0d 00 5a 00 00 0c 00 | 00 15 00 74 0c 00 00 16 |...Z....|...t....|
|000032e0| 00 7a 0c 00 00 15 00 7b | 0c 00 00 16 00 84 0c 00 |.z.....{|........|
|000032f0| 00 15 00 a9 0c 04 00 15 | 00 af 0c 00 00 15 00 c0 |........|........|
|00003300| 0c 00 00 16 00 c5 0c 00 | 00 15 00 f1 0c 00 00 16 |........|........|
|00003310| 00 f6 0c 00 00 15 01 13 | 0c 00 00 16 01 16 0c 00 |........|........|
|00003320| 00 15 01 50 0c 00 00 16 | 01 53 0c 00 00 15 00 01 |...P....|.S......|
|00003330| 0d ff 00 06 00 00 0c 00 | 00 15 00 cb 09 57 6f 72 |........|.....Wor|
|00003340| 6b 61 72 6f 75 6e 64 3a | 20 20 57 68 65 6e 20 75 |karound:| When u|
|00003350| 73 69 6e 67 20 74 68 65 | 20 2d 6d 63 36 38 30 32 |sing the| -mc6802|
|00003360| 30 20 63 6f 6d 70 69 6c | 65 72 20 6f 70 74 69 6f |0 compil|er optio|
|00003370| 6e 2c 20 65 69 74 68 65 | 72 20 64 6f 6e d5 74 20 |n, eithe|r don.t |
|00003380| 70 61 73 73 20 73 74 72 | 75 63 74 75 72 65 73 20 |pass str|uctures |
|00003390| 6c 61 72 67 65 72 20 74 | 68 61 6e 20 34 20 62 79 |larger t|han 4 by|
|000033a0| 74 65 73 20 62 79 20 76 | 61 6c 75 65 2c 20 6f 72 |tes by v|alue, or|
|000033b0| 20 6d 61 6b 65 20 73 75 | 72 65 20 61 6c 6c 20 73 | make su|re all s|
|000033c0| 74 72 75 63 74 75 72 65 | 73 20 6c 61 72 67 65 72 |tructure|s larger|
|000033d0| 20 74 68 61 6e 20 34 20 | 62 79 74 65 73 20 61 72 | than 4 |bytes ar|
|000033e0| 65 20 70 61 64 64 65 64 | 20 6f 75 74 20 74 6f 20 |e padded| out to |
|000033f0| 61 20 6d 75 6c 74 69 70 | 6c 65 20 6f 66 20 34 20 |a multip|le of 4 |
|00003400| 62 79 74 65 73 2e 0d 00 | 00 18 00 00 0c 01 00 15 |bytes...|........|
|00003410| 00 0c 0c 00 00 15 00 1d | 0c 00 00 16 00 25 0c 00 |........|.....%..|
|00003420| 00 15 00 01 0d 00 00 06 | 00 00 0c 00 00 15 00 01 |........|........|
|00003430| 0d 00 00 06 00 00 0c 00 | 00 15 00 38 09 3b 2d 2d |........|...8.;--|
|00003440| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003450| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003460| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003470| 2d 2d 2d 0d 00 06 00 00 | 09 00 00 16 00 00 ff d6 |---.....|........|
|00003480| 00 17 03 be 00 0d 4d 41 | 47 49 43 50 49 43 11 01 |......MA|GICPIC..|
|00003490| ff bf 00 08 09 66 6f 6f | 28 69 29 0d 00 06 00 00 |.....foo|(i).....|
|000034a0| 09 00 00 16 00 00 ff d6 | 00 49 03 be 00 0d 4d 41 |........|.I....MA|
|000034b0| 47 49 43 50 49 43 11 01 | ff 62 00 15 00 01 0d 00 |GICPIC..|.b......|
|000034c0| 00 06 00 00 0c 00 00 15 | 00 24 01 e6 03 0a 00 00 |........|.$......|
|000034d0| 00 12 00 31 00 5a 00 82 | 00 a6 00 cf 00 f7 01 20 |...1.Z..|....... |
|000034e0| 01 48 01 71 01 99 02 26 | 02 26 00 14 09 23 69 6e |.H.q...&|.&...#in|
|000034f0| 63 6c 75 64 65 20 3c 73 | 74 64 69 6f 2e 68 3e 0d |clude <s|tdio.h>.|
|00003500| 00 06 00 00 09 00 00 16 | 00 16 09 23 69 6e 63 6c |........|...#incl|
|00003510| 75 64 65 20 3c 73 74 72 | 69 6e 67 73 2e 68 3e 0d |ude <str|ings.h>.|
|00003520| 00 06 00 00 09 00 00 16 | 00 08 09 6d 61 69 6e 28 |........|...main(|
|00003530| 29 0d 00 06 00 00 09 00 | 00 16 00 03 09 7b 0d 00 |).......|.....{..|
|00003540| 00 06 00 00 09 00 00 16 | 00 18 09 09 75 6e 73 69 |........|....unsi|
|00003550| 67 6e 65 64 20 73 68 6f | 72 74 20 77 20 3d 20 31 |gned sho|rt w = 1|
|00003560| 3b 0d 00 06 00 00 09 00 | 00 16 00 03 09 09 0d 00 |;.......|........|
|00003570| 00 06 00 00 09 00 00 16 | 00 2f 09 09 70 72 69 6e |........|./..prin|
|00003580| 74 66 28 22 54 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |tf("The |followin|
|00003590| 67 20 74 65 73 74 20 66 | 61 69 6c 73 20 69 6e 20 |g test f|ails in |
|000035a0| 4d 50 57 5c 6e 22 29 3b | 0d 00 00 06 00 00 09 00 |MPW\n");|........|
|000035b0| 00 16 00 32 09 09 70 72 | 69 6e 74 66 28 22 53 68 |...2..pr|intf("Sh|
|000035c0| 6f 75 6c 64 20 73 77 69 | 74 63 68 20 74 6f 20 31 |ould swi|tch to 1|
|000035d0| 3b 20 61 63 74 75 61 6c | 6c 79 20 67 6f 74 20 74 |; actual|ly got t|
|000035e0| 6f 20 22 29 3b 0d 00 06 | 00 00 09 00 00 16 00 03 |o ");...|........|
|000035f0| 09 09 0d 00 00 06 00 00 | 09 00 00 16 00 12 01 e6 |........|........|
|00003600| 03 0a 00 00 00 12 00 31 | 00 5a 00 82 00 a6 00 cf |.......1|.Z......|
|00003610| 00 f7 01 20 01 48 01 71 | 01 99 02 10 02 10 00 01 |... .H.q|........|
|00003620| 0d 00 00 06 00 00 0c 00 | 00 15 47 49 43 50 49 43 |........|..GICPIC|
|00003630| 11 01 ff 96 00 0f 09 09 | 73 77 69 74 63 68 20 28 |........|switch (|
|00003640| 77 29 20 7b 0d 00 00 06 | 00 00 09 00 00 16 00 0b |w) {....|........|
|00003650| 09 09 09 63 61 73 65 20 | 31 3a 0d 00 00 06 00 00 |...case |1:......|
|00003660| 09 00 00 16 00 13 09 09 | 09 09 70 72 69 6e 74 66 |........|..printf|
|00003670| 28 22 31 5c 6e 22 29 3b | 0d 00 00 06 00 00 09 00 |("1\n");|........|
|00003680| 00 16 00 0b 09 09 09 09 | 62 72 65 61 6b 3b 0d 00 |........|break;..|
|00003690| 00 06 00 00 09 00 00 16 | 00 0b 09 09 09 63 61 73 |........|.....cas|
|000036a0| 65 20 35 3a 0d 00 00 06 | 00 00 09 00 00 16 00 13 |e 5:....|........|
|000036b0| 09 09 09 09 70 72 69 6e | 74 66 28 22 35 5c 6e 22 |....prin|tf("5\n"|
|000036c0| 29 3b 0d 00 00 06 00 00 | 09 00 00 16 00 0b 09 09 |);......|........|
|000036d0| 09 09 62 72 65 61 6b 3b | 0d 00 00 06 00 00 09 00 |..break;|........|
|000036e0| 00 16 00 0f 09 09 09 63 | 61 73 65 20 33 32 37 37 |.......c|ase 3277|
|000036f0| 31 3a 0d 00 00 06 00 00 | 09 00 00 16 00 17 09 09 |1:......|........|
|00003700| 09 09 70 72 69 6e 74 66 | 28 22 33 32 37 37 31 5c |..printf|("32771\|
|00003710| 6e 22 29 3b 0d 00 00 06 | 00 00 09 00 00 16 00 0b |n");....|........|
|00003720| 09 09 09 09 62 72 65 61 | 6b 3b 0d 00 00 06 00 00 |....brea|k;......|
|00003730| 09 00 00 16 00 0f 09 09 | 09 63 61 73 65 20 33 32 |........|.case 32|
|00003740| 37 37 33 3a 0d 00 00 06 | 00 00 09 00 00 16 00 17 |773:....|........|
|00003750| 09 09 09 09 70 72 69 6e | 74 66 28 22 33 32 37 37 |....prin|tf("3277|
|00003760| 33 5c 6e 22 29 3b 0d 00 | 00 06 00 00 09 00 00 16 |3\n");..|........|
|00003770| 00 0b 09 09 09 09 62 72 | 65 61 6b 3b 0d 00 00 06 |......br|eak;....|
|00003780| 00 00 09 00 00 16 00 0c | 09 09 09 64 65 66 61 75 |........|...defau|
|00003790| 6c 74 3a 0d 00 06 00 00 | 09 00 00 16 00 19 09 09 |lt:.....|........|
|000037a0| 09 09 70 72 69 6e 74 66 | 28 22 64 65 66 61 75 6c |..printf|("defaul|
|000037b0| 74 5c 6e 22 29 3b 0d 00 | 00 06 00 00 09 00 00 16 |t\n");..|........|
|000037c0| 00 0b 09 09 09 09 62 72 | 65 61 6b 3b 0d 00 00 06 |......br|eak;....|
|000037d0| 00 00 09 00 00 16 00 04 | 09 09 7d 0d 00 06 00 00 |........|..}.....|
|000037e0| 09 00 00 16 00 03 09 7d | 0d 00 00 06 00 00 09 00 |.......}|........|
|000037f0| 00 16 00 12 01 e6 03 0a | 00 00 00 12 00 31 00 5a |........|.....1.Z|
|00003800| 00 82 00 a6 00 cf 00 f7 | 01 20 01 48 01 71 01 99 |........|. .H.q..|
|00003810| 02 26 02 26 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |.&.&....|........|
|00003820| 03 05 09 49 6e 20 74 68 | 69 73 20 65 78 61 6d 70 |...In th|is examp|
|00003830| 6c 65 2c 20 69 6e 73 74 | 65 61 64 20 6f 66 20 72 |le, inst|ead of r|
|00003840| 65 61 63 68 69 6e 67 20 | 63 61 73 65 20 31 3a 20 |eaching |case 1: |
|00003850| 69 6e 20 74 68 65 20 73 | 77 69 74 63 68 20 73 74 |in the s|witch st|
|00003860| 61 74 65 6d 65 6e 74 2c | 20 74 68 65 20 64 65 66 |atement,| the def|
|00003870| 61 75 6c 74 3a 20 63 61 | 73 65 20 69 73 20 72 65 |ault: ca|se is re|
|00003880| 61 63 68 65 64 20 64 75 | 65 20 74 6f 20 74 68 65 |ached du|e to the|
|00003890| 20 66 61 63 74 20 74 68 | 61 74 20 74 68 65 20 63 | fact th|at the c|
|000038a0| 6f 6d 70 69 6c 65 72 20 | 67 65 6e 65 72 61 74 65 |ompiler |generate|
|000038b0| 73 20 63 6f 6d 70 61 72 | 69 73 6f 6e 20 69 6e 73 |s compar|ison ins|
|000038c0| 74 72 75 63 74 69 6f 6e | 73 20 62 61 73 65 64 20 |truction|s based |
|000038d0| 6f 6e 20 77 6f 72 64 20 | 6c 65 6e 67 74 68 20 76 |on word |length v|
|000038e0| 61 6c 75 65 73 2e 20 54 | 68 65 20 31 73 74 20 45 |alues. T|he 1st E|
|000038f0| 64 69 74 69 6f 6e 20 6f | 66 20 4b 26 52 20 28 54 |dition o|f K&R (T|
|00003900| 68 65 20 43 20 50 72 6f | 67 72 61 6d 6d 69 6e 67 |he C Pro|gramming|
|00003910| 20 4c 61 6e 67 75 61 67 | 65 2c 20 4b 65 72 6e 69 | Languag|e, Kerni|
|00003920| 67 68 61 6e 20 26 20 52 | 69 74 63 68 69 65 2c 20 |ghan & R|itchie, |
|00003930| 31 39 37 38 2c 20 41 70 | 70 65 6e 64 69 78 20 41 |1978, Ap|pendix A|
|00003940| 20 53 65 63 2e 20 39 2e | 37 2c 20 70 32 30 32 29 | Sec. 9.|7, p202)|
|00003950| 20 72 65 71 75 69 72 65 | 73 20 61 6c 6c 20 63 61 | require|s all ca|
|00003960| 73 65 20 63 6f 6e 73 74 | 61 6e 74 73 20 74 6f 20 |se const|ants to |
|00003970| 68 61 76 65 20 69 6e 74 | 65 67 65 72 20 74 79 70 |have int|eger typ|
|00003980| 65 20 61 6e 64 20 74 68 | 65 20 63 6f 6e 74 72 6f |e and th|e contro|
|00003990| 6c 6c 69 6e 67 20 65 78 | 70 72 65 73 73 69 6f 6e |lling ex|pression|
|000039a0| 20 74 6f 20 62 65 20 63 | 6f 65 72 63 65 64 20 74 | to be c|oerced t|
|000039b0| 6f 20 69 6e 74 65 67 65 | 72 20 74 79 70 65 2e 20 |o intege|r type. |
|000039c0| 20 54 68 65 20 20 32 6e | 64 20 45 64 69 74 69 6f | The 2n|d Editio|
|000039d0| 6e 20 28 41 4e 53 49 29 | 20 6f 66 20 4b 26 52 20 |n (ANSI)| of K&R |
|000039e0| 28 54 68 65 20 43 20 50 | 72 6f 67 72 61 6d 6d 69 |(The C P|rogrammi|
|000039f0| 6e 67 20 4c 61 6e 67 75 | 61 67 65 2c 20 4b 65 72 |ng Langu|age, Ker|
|00003a00| 6e 69 67 68 61 6e 20 26 | 20 52 69 74 63 68 69 65 |nighan &| Ritchie|
|00003a10| 2c 20 31 39 38 38 2c 20 | 41 70 70 65 6e 64 69 78 |, 1988, |Appendix|
|00003a20| 20 41 20 53 65 63 2e 20 | 39 2e 34 2c 20 70 32 32 | A Sec. |9.4, p22|
|00003a30| 33 29 20 72 65 71 75 69 | 72 65 73 20 74 68 61 74 |3) requi|res that|
|00003a40| 20 74 68 65 20 63 6f 6e | 74 72 6f 6c 6c 69 6e 67 | the con|trolling|
|00003a50| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 61 6e 64 20 | express|ion and |
|00003a60| 61 6c 6c 20 63 61 73 65 | 20 63 6f 6e 73 74 61 6e |all case| constan|
|00003a70| 74 73 20 75 6e 64 65 72 | 67 6f 20 d2 69 6e 74 65 |ts under|go .inte|
|00003a80| 67 72 61 6c 20 70 72 6f | 6d 6f 74 69 6f 6e d3 d1 |gral pro|motion..|
|00003a90| 70 72 6f 6d 6f 74 69 6f | 6e 20 74 6f 20 69 6e 74 |promotio|n to int|
|00003aa0| 20 28 6f 72 20 74 6f 20 | 75 6e 73 69 67 6e 65 64 | (or to |unsigned|
|00003ab0| 20 69 6e 74 20 69 66 20 | 6e 65 63 65 73 73 61 72 | int if |necessar|
|00003ac0| 79 29 2e 20 20 4d 50 57 | 20 32 2e 30 2e 32 20 43 |y). MPW| 2.0.2 C|
|00003ad0| 20 66 61 69 6c 73 20 74 | 6f 20 70 72 6f 6d 6f 74 | fails t|o promot|
|00003ae0| 65 20 65 69 74 68 65 72 | 20 74 68 65 20 63 6f 6e |e either| the con|
|00003af0| 74 72 6f 6c 6c 69 6e 67 | 20 65 78 70 72 65 73 73 |trolling| express|
|00003b00| 69 6f 6e 20 6f 72 20 74 | 68 65 20 63 61 73 65 20 |ion or t|he case |
|00003b10| 63 6f 6e 73 74 61 6e 74 | 73 20 74 6f 20 74 79 70 |constant|s to typ|
|00003b20| 65 20 69 6e 74 2e 0d ff | 00 5a 00 00 0c 00 00 15 |e int...|.Z......|
|00003b30| 00 26 0c 00 00 16 00 2d | 0c 00 00 15 00 4b 0c 00 |.&.....-|.....K..|
|00003b40| 00 16 00 53 0c 00 00 15 | 00 dd 0c 02 00 15 00 f7 |...S....|........|
|00003b50| 0c 00 00 15 01 bf 0c 02 | 00 15 01 d9 0c 00 00 15 |........|........|
|00003b60| 02 7b 0c 00 00 16 02 7e | 0c 00 00 15 02 86 0c 00 |.{.....~|........|
|00003b70| 00 16 02 92 0c 00 00 15 | 03 00 0c 00 00 16 03 03 |........|........|
|00003b80| 0c 00 00 15 00 02 09 0d | 00 06 00 00 0c 00 00 15 |........|........|
|00003b90| 00 6e 09 57 6f 72 6b 61 | 72 6f 75 6e 64 3a 20 20 |.n.Worka|round: |
|00003ba0| 49 66 20 74 68 65 20 63 | 6f 6e 74 72 6f 6c 6c 69 |If the c|ontrolli|
|00003bb0| 6e 67 20 65 78 70 72 65 | 73 73 69 6f 6e 20 69 73 |ng expre|ssion is|
|00003bc0| 20 6d 61 6e 75 61 6c 6c | 79 20 63 6f 65 72 63 65 | manuall|y coerce|
|00003bd0| 64 20 74 6f 20 74 79 70 | 65 20 69 6e 74 20 74 68 |d to typ|e int th|
|00003be0| 69 73 20 65 78 61 6d 70 | 6c 65 20 66 75 6e 63 74 |is examp|le funct|
|00003bf0| 69 6f 6e 73 20 63 6f 72 | 72 65 63 74 6c 79 2e 0d |ions cor|rectly..|
|00003c00| 00 18 00 00 0c 01 00 15 | 00 0c 0c 00 00 15 00 48 |........|.......H|
|00003c10| 0c 00 00 16 00 4b 0c 00 | 00 15 00 01 0d 00 00 06 |.....K..|........|
|00003c20| 00 00 0c 00 00 15 00 01 | 0d 00 00 06 00 00 0c 00 |........|........|
|00003c30| 00 15 00 fc 37 29 09 56 | 61 72 69 61 62 6c 65 20 |....7).V|ariable |
|00003c40| 64 65 63 6c 61 72 61 74 | 69 6f 6e 73 20 69 6e 73 |declarat|ions ins|
|00003c50| 69 64 65 20 74 68 65 20 | 62 6f 64 79 20 6f 66 20 |ide the |body of |
|00003c60| 73 77 69 74 63 68 20 73 | 74 61 74 65 6d 65 6e 74 |switch s|tatement|
|00003c70| 73 2c 20 77 68 65 6e 20 | 63 6f 6d 62 69 6e 65 64 |s, when |combined|
|00003c80| 20 77 69 74 68 20 74 68 | 65 20 2d 67 20 63 6f 6d | with th|e -g com|
|00003c90| 70 69 6c 65 72 20 66 6c | 61 67 2c 20 63 61 6e 20 |piler fl|ag, can |
|00003ca0| 63 61 75 73 65 20 74 68 | 65 20 63 6f 6d 70 69 6c |cause th|e compil|
|00003cb0| 65 72 d5 73 20 63 6f 64 | 65 20 67 65 6e 65 72 61 |er.s cod|e genera|
|00003cc0| 74 6f 72 20 74 6f 20 61 | 62 6f 72 74 20 77 69 74 |tor to a|bort wit|
|00003cd0| 68 20 74 68 65 20 6d 65 | 73 73 61 67 65 3a 20 d2 |h the me|ssage: .|
|00003ce0| 43 6f 64 65 20 67 65 6e | 65 72 61 74 6f 72 20 61 |Code gen|erator a|
|00003cf0| 62 6f 72 74 20 63 6f 64 | 65 20 36 31 35 2e d3 20 |bort cod|e 615.. |
|00003d00| 20 54 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 65 | The fol|lowing e|
|00003d10| 78 61 6d 70 6c 65 20 69 | 6c 6c 75 73 74 72 61 74 |xample i|llustrat|
|00003d20| 65 73 20 74 68 65 20 70 | 72 6f 62 6c 65 6d 3a 0d |es the p|roblem:.|
|00003d30| 00 12 00 00 0c 00 00 15 | 00 56 0c 00 00 16 00 58 |........|.V.....X|
|00003d40| 0c 00 00 15 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |........|........|
|00003d50| 00 24 01 e6 03 0a 00 00 | 00 12 00 31 00 5a 00 82 |.$......|...1.Z..|
|00003d60| 00 a6 00 cf 00 f7 01 20 | 01 48 01 71 01 99 02 26 |....... |.H.q...&|
|00003d70| 02 26 00 01 0d 00 00 06 | 00 00 0c 00 00 15 00 00 |.&......|........|
|00003d80| 09 00 00 16 00 09 09 09 | 69 6e 74 20 69 3b 0d 00 |........|int i;..|
|00003d90| 00 06 00 00 09 00 00 16 | 00 03 09 7b 0d 00 00 06 |........|...{....|
|00003da0| 00 00 09 00 00 16 00 0f | 09 09 73 77 69 74 63 68 |........|..switch|
|00003db0| 20 28 69 29 20 7b 0d 00 | 00 06 00 00 09 00 00 16 | (i) {..|........|
|00003dc0| 00 3d 09 09 09 69 6e 74 | 20 6a 3b 20 20 20 2f 2a |.=...int| j; /*|
|00003dd0| 20 56 41 52 49 41 42 4c | 45 20 44 45 43 4c 41 52 | VARIABL|E DECLAR|
|00003de0| 41 54 49 4f 4e 20 49 4e | 53 49 44 45 20 42 4f 44 |ATION IN|SIDE BOD|
|00003df0| 59 20 4f 46 20 53 57 49 | 54 43 48 20 2a 2f 0d 00 |Y OF SWI|TCH */..|
|00003e00| 00 06 00 00 09 00 00 16 | 00 04 09 09 09 0d 00 06 |........|........|
|00003e10| 00 00 09 00 00 16 00 04 | 09 09 09 0d 00 06 00 00 |........|........|
|00003e20| 09 00 00 16 00 0b 09 09 | 09 63 61 73 65 20 30 3a |........|.case 0:|
|00003e30| 0d 00 00 06 00 00 09 00 | 00 16 00 0f 09 09 09 09 |........|........|
|00003e40| 6a 20 3d 20 32 32 20 2b | 69 3b 0d 00 00 06 00 00 |j = 22 +|i;......|
|00003e50| 09 00 00 16 00 2a 09 09 | 09 09 70 72 69 6e 74 66 |.....*..|..printf|
|00003e60| 28 22 49 4e 53 49 44 45 | 3a 20 69 3d 25 64 2c 20 |("INSIDE|: i=%d, |
|00003e70| 6a 3d 25 64 5c 6e 22 2c | 20 69 2c 20 6a 29 3b 0d |j=%d\n",| i, j);.|
|00003e80| 00 06 00 00 09 00 00 16 | 00 0b 09 09 09 09 62 72 |........|......br|
|00003e90| 65 61 6b 3b 0d 00 00 06 | 00 00 09 00 00 16 00 0b |eak;....|........|
|00003ea0| 09 09 09 63 61 73 65 20 | 31 3a 0d 00 00 06 00 00 |...case |1:......|
|00003eb0| 09 00 00 16 00 0f 09 09 | 09 09 6a 20 3d 20 35 37 |........|..j = 57|
|00003ec0| 20 2d 69 3b 0d 00 00 06 | 00 00 09 00 00 16 00 2a | -i;....|.......*|
|00003ed0| 09 09 09 09 70 72 69 6e | 74 66 28 22 49 4e 53 49 |....prin|tf("INSI|
|00003ee0| 44 45 3a 20 69 3d 25 64 | 2c 20 6a 3d 25 64 5c 6e |DE: i=%d|, j=%d\n|
|00003ef0| 22 2c 20 69 2c 20 6a 29 | 3b 0d 00 06 00 00 09 00 |", i, j)|;.......|
|00003f00| 00 16 00 0b 09 09 09 09 | 62 72 65 61 6b 3b 0d 00 |........|break;..|
|00003f10| 00 06 00 00 09 00 00 16 | 00 0c 09 09 09 64 65 66 |........|.....def|
|00003f20| 61 75 6c 74 3a 0d 00 06 | 00 00 09 00 00 16 00 0b |ault:...|........|
|00003f30| 09 09 09 09 6a 20 3d 20 | 69 3b 0d 00 00 06 00 00 |....j = |i;......|
|00003f40| 09 00 00 16 00 2a 09 09 | 09 09 70 72 69 6e 74 66 |.....*..|..printf|
|00003f50| 28 22 49 4e 53 49 44 45 | 3a 20 69 3d 25 64 2c 20 |("INSIDE|: i=%d, |
|00003f60| 6a 3d 25 64 5c 6e 22 2c | 20 69 2c 20 6a 29 3b 0d |j=%d\n",| i, j);.|
|00003f70| 00 06 00 00 09 00 00 16 | 00 0b 09 09 09 09 62 72 |........|......br|
|00003f80| 65 61 6b 3b 0d 00 00 06 | 00 00 09 00 00 16 00 04 |eak;....|........|
|00003f90| 09 09 7d 0d 00 06 00 00 | 09 00 00 16 00 03 09 7d |..}.....|.......}|
|00003fa0| 0d 00 00 06 00 00 09 00 | 00 16 00 12 01 e6 03 0a |........|........|
|00003fb0| 00 00 00 12 00 31 00 5a | 00 82 00 a6 00 cf 00 f7 |.....1.Z|........|
|00003fc0| 01 20 01 48 01 71 01 99 | 02 26 02 26 00 01 0d 00 |. .H.q..|.&.&....|
|00003fd0| 00 06 00 00 0c 00 00 15 | 01 53 09 57 68 69 6c 65 |........|.S.While|
|00003fe0| 20 73 75 63 68 20 61 20 | 64 65 63 6c 61 72 61 74 | such a |declarat|
|00003ff0| 69 6f 6e 20 69 73 20 70 | 65 72 66 65 63 74 6c 79 |ion is p|erfectly|
|00004000| 20 6c 65 67 61 6c 20 43 | 2c 20 69 74 20 69 73 20 | legal C|, it is |
|00004010| 61 20 62 61 64 20 70 72 | 61 63 74 69 63 65 20 28 |a bad pr|actice (|
|00004020| 54 68 65 20 43 20 50 72 | 6f 67 72 61 6d 6d 69 6e |The C Pr|ogrammin|
|00004030| 67 20 4c 61 6e 67 75 61 | 67 65 2c 20 4b 65 72 6e |g Langua|ge, Kern|
|00004040| 69 67 68 61 6e 20 26 20 | 52 69 74 63 68 69 65 2c |ighan & |Ritchie,|
|00004050| 20 31 39 37 38 2c 20 41 | 70 70 65 6e 64 69 78 20 | 1978, A|ppendix |
|00004060| 41 20 53 65 63 2e 20 39 | 2e 32 2c 20 70 32 30 31 |A Sec. 9|.2, p201|
|00004070| 29 2e 20 4b 26 52 20 67 | 6f 20 6f 6e 20 74 6f 20 |). K&R g|o on to |
|00004080| 70 6f 69 6e 74 20 6f 75 | 74 20 74 68 61 74 20 69 |point ou|t that i|
|00004090| 66 20 74 68 65 20 64 65 | 63 6c 61 72 61 74 69 6f |f the de|claratio|
|000040a0| 6e 20 6f 66 20 74 68 65 | 20 76 61 72 69 61 62 6c |n of the| variabl|
|000040b0| 65 20 63 6f 6e 74 61 69 | 6e 73 20 61 6e 20 69 6e |e contai|ns an in|
|000040c0| 69 74 69 61 6c 69 7a 65 | 72 2c 20 74 68 65 20 69 |itialize|r, the i|
|000040d0| 6e 69 74 69 61 6c 69 7a | 61 74 69 6f 6e 20 77 69 |nitializ|ation wi|
|000040e0| 6c 6c 20 4e 4f 54 20 74 | 61 6b 65 20 70 6c 61 63 |ll NOT t|ake plac|
|000040f0| 65 2e 20 20 54 68 69 73 | 20 69 73 20 61 6c 73 6f |e. This| is also|
|00004100| 20 74 68 65 20 41 4e 53 | 49 20 64 72 61 66 74 20 | the ANS|I draft |
|00004110| 43 20 73 74 61 6e 64 61 | 72 64 d5 73 20 69 6e 74 |C standa|rd.s int|
|00004120| 65 72 70 72 65 74 61 74 | 69 6f 6e 2e 0d 00 00 12 |erpretat|ion.....|
|00004130| 00 00 0c 00 00 15 00 46 | 0c 02 00 15 00 60 0c 00 |.......F|.....`..|
|00004140| 00 15 00 01 0d 00 00 06 | 00 00 0c 00 00 15 00 8d |........|........|
|00004150| 09 57 6f 72 6b 61 72 6f | 75 6e 64 3a 20 20 53 69 |.Workaro|und: Si|
|00004160| 6e 63 65 20 74 68 65 20 | 2d 67 20 6f 70 74 69 6f |nce the |-g optio|
|00004170| 6e 20 69 73 20 61 20 76 | 65 72 79 20 75 73 65 66 |n is a v|ery usef|
|00004180| 75 6c 20 64 65 62 75 67 | 67 69 6e 67 20 6f 70 74 |ul debug|ging opt|
|00004190| 69 6f 6e 2c 20 6d 6f 76 | 65 20 74 68 65 20 76 61 |ion, mov|e the va|
|000041a0| 72 69 61 62 6c 65 20 64 | 65 63 6c 61 72 61 74 69 |riable d|eclarati|
|000041b0| 6f 6e 20 6f 75 74 73 69 | 64 65 20 74 68 65 20 62 |on outsi|de the b|
|000041c0| 6f 64 79 20 6f 66 20 74 | 68 65 20 73 77 69 74 63 |ody of t|he switc|
|000041d0| 68 20 73 74 61 74 65 6d | 65 6e 74 2e 0d 00 00 18 |h statem|ent.....|
|000041e0| 00 00 0c 01 00 15 00 0c | 0c 00 00 15 00 18 0c 00 |........|........|
|000041f0| 00 16 00 1a 0c 00 00 15 | 00 01 0d 00 00 06 00 00 |........|........|
|00004200| 0c 00 00 15 01 9f 38 29 | 09 43 6f 6d 70 61 74 69 |......8)|.Compati|
|00004210| 62 69 6c 69 74 79 20 4e | 6f 74 65 3a 20 20 4c 6f |bility N|ote: Lo|
|00004220| 63 61 6c 20 76 61 72 69 | 61 62 6c 65 20 64 65 63 |cal vari|able dec|
|00004230| 6c 61 72 61 74 69 6f 6e | 73 20 6f 66 20 74 68 65 |laration|s of the|
|00004240| 20 66 6f 72 6d 20 63 68 | 61 72 20 73 5b 5d 3b 20 | form ch|ar s[]; |
|00004250| 28 61 73 20 61 6e 20 61 | 72 72 61 79 20 6f 66 20 |(as an a|rray of |
|00004260| 75 6e 73 70 65 63 69 66 | 69 65 64 20 6c 65 6e 67 |unspecif|ied leng|
|00004270| 74 68 29 2c 20 6d 61 79 | 20 6e 6f 74 20 62 65 68 |th), may| not beh|
|00004280| 61 76 65 20 61 73 20 65 | 78 70 65 63 74 65 64 2e |ave as e|xpected.|
|00004290| 20 50 72 65 2d 41 4e 53 | 49 20 63 6f 6d 70 69 6c | Pre-ANS|I compil|
|000042a0| 65 72 73 20 6f 66 74 65 | 6e 20 65 78 70 61 6e 64 |ers ofte|n expand|
|000042b0| 20 73 75 63 68 20 64 65 | 63 6c 61 72 61 74 69 6f | such de|claratio|
|000042c0| 6e 73 20 69 6e 74 6f 20 | 74 68 65 20 65 71 75 69 |ns into |the equi|
|000042d0| 76 61 6c 65 6e 74 20 6f | 66 20 61 6e 20 65 78 74 |valent o|f an ext|
|000042e0| 65 72 6e 20 64 65 63 6c | 61 72 61 74 69 6f 6e 2e |ern decl|aration.|
|000042f0| 20 4d 50 57 20 32 2e 30 | 2e 32 20 43 2c 20 61 6e | MPW 2.0|.2 C, an|
|00004300| 64 20 6d 6f 73 74 20 6d | 6f 64 65 72 6e 20 63 6f |d most m|odern co|
|00004310| 6d 70 69 6c 65 72 73 2c | 20 74 72 65 61 74 20 74 |mpilers,| treat t|
|00004320| 68 69 73 20 63 6f 6e 73 | 74 72 75 63 74 20 61 73 |his cons|truct as|
|00004330| 20 74 68 65 20 64 65 63 | 6c 61 72 61 74 69 6f 6e | the dec|laration|
|00004340| 20 6f 66 20 61 20 6e 65 | 77 20 61 72 72 61 79 2c | of a ne|w array,|
|00004350| 20 74 68 75 73 20 6f 76 | 65 72 72 69 64 69 6e 67 | thus ov|erriding|
|00004360| 20 61 6e 79 20 67 6c 6f | 62 61 6c 20 64 65 63 6c | any glo|bal decl|
|00004370| 61 72 61 74 69 6f 6e 20 | 77 69 74 68 20 74 68 65 |aration |with the|
|00004380| 20 73 61 6d 65 20 6e 61 | 6d 65 2e 20 49 6e 20 74 | same na|me. In t|
|00004390| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 65 78 61 |he follo|wing exa|
|000043a0| 6d 70 6c 65 0d ff 00 1e | 00 00 0c 00 00 15 00 40 |mple....|.......@|
|000043b0| 0c 00 00 16 00 49 0c 00 | 00 15 01 40 0c 04 00 15 |.....I..|...@....|
|000043c0| 01 44 0c 00 00 15 00 01 | 0d 00 00 06 00 00 0c 00 |.D......|........|
|000043d0| 00 15 00 24 01 e6 03 0a | 00 00 00 12 00 31 00 5a |...$....|.....1.Z|
|000043e0| 00 82 00 a6 00 cf 00 f7 | 01 20 01 48 01 71 01 99 |........|. .H.q..|
|000043f0| 02 26 02 26 00 17 09 2f | 2a 20 46 72 6f 6d 20 66 |.&.&.../|* From f|
|00004400| 69 6c 65 20 66 6f 6f 2e | 63 20 2a 2f 0d 00 00 06 |ile foo.|c */....|
|00004410| 00 00 09 00 00 16 00 0e | 09 63 68 61 72 20 73 5b |........|.char s[|
|00004420| 32 35 35 5d 3b 0d 00 06 | 00 00 09 00 00 16 00 02 |255];...|........|
|00004430| 09 0d 00 06 00 00 09 00 | 00 16 00 08 09 6d 61 69 |........|.....mai|
|00004440| 6e 28 29 0d 00 06 00 00 | 09 00 00 16 00 03 09 7b |n().....|.......{|
|00004450| 0d 00 00 06 00 00 09 00 | 00 16 00 2b 09 09 73 74 |........|...+..st|
|00004460| 72 63 70 79 28 73 2c 20 | 22 54 68 69 73 20 69 73 |rcpy(s, |"This is|
|00004470| 20 6f 6e 65 20 68 65 63 | 6b 20 6f 66 20 61 20 6d | one hec|k of a m|
|00004480| 65 73 73 22 29 3b 0d 00 | 00 06 00 00 09 00 00 16 |ess");..|........|
|00004490| 00 0f 09 09 6f 74 68 65 | 72 66 75 6e 63 28 29 3b |....othe|rfunc();|
|000044a0| 0d 00 00 06 00 00 09 00 | 00 16 00 03 09 7d 0d 00 |........|.....}..|
|000044b0| 00 06 00 00 09 00 00 16 | 00 02 09 0d 00 06 00 00 |........|........|
|000044c0| 09 00 00 16 00 02 09 0d | 00 06 00 00 09 00 00 16 |........|........|
|000044d0| 00 17 09 2f 2a 20 46 72 | 6f 6d 20 66 69 6c 65 20 |.../* Fr|om file |
|000044e0| 62 61 72 2e 63 20 2a 2f | 0d 00 00 06 00 00 09 00 |bar.c */|........|
|000044f0| 00 16 00 0d 09 6f 74 68 | 65 72 66 75 6e 63 28 29 |.....oth|erfunc()|
|00004500| 0d 00 00 06 00 00 09 00 | 00 16 00 03 09 7b 0d 00 |........|.....{..|
|00004510| 00 06 00 00 09 00 00 16 | 00 0c 09 09 63 68 61 72 |........|....char|
|00004520| 20 73 5b 5d 3b 0d 00 06 | 00 00 09 00 00 16 00 03 | s[];...|........|
|00004530| 09 09 0d 00 00 06 00 00 | 09 00 00 16 00 15 09 09 |........|........|
|00004540| 70 72 69 6e 74 66 28 22 | 25 73 5c 6e 22 2c 20 73 |printf("|%s\n", s|
|00004550| 29 3b 0d ff 00 06 00 00 | 09 00 00 16 00 03 09 7d |);......|.......}|
|00004560| 0d 00 00 06 00 00 09 00 | 00 16 00 12 01 e6 03 0a |........|........|
|00004570| 00 00 00 12 00 31 00 5a | 00 82 00 a6 00 cf 00 f7 |.....1.Z|........|
|00004580| 01 20 01 48 01 71 01 99 | 02 26 02 26 00 01 0d 00 |. .H.q..|.&.&....|
|00004590| 00 06 00 00 0c 00 00 15 | 01 25 09 67 61 72 62 61 |........|.%.garba|
|000045a0| 67 65 20 69 73 20 70 72 | 69 6e 74 65 64 2e 20 20 |ge is pr|inted. |
|000045b0| 41 73 20 61 20 6c 6f 63 | 61 6c 20 76 61 72 69 61 |As a loc|al varia|
|000045c0| 62 6c 65 20 64 65 63 6c | 61 72 61 74 69 6f 6e 2c |ble decl|aration,|
|000045d0| 20 74 68 69 73 20 64 65 | 63 6c 61 72 61 74 69 6f | this de|claratio|
|000045e0| 6e 20 69 73 20 69 6e 63 | 6f 6d 70 6c 65 74 65 20 |n is inc|omplete |
|000045f0| 73 69 6e 63 65 20 6e 6f | 20 6c 65 6e 67 74 68 20 |since no| length |
|00004600| 69 73 20 73 70 65 63 69 | 66 69 65 64 20 6f 72 20 |is speci|fied or |
|00004610| 69 6d 70 6c 69 65 64 2c | 20 73 6f 20 61 6e 20 41 |implied,| so an A|
|00004620| 4e 53 49 20 43 20 63 6f | 6d 70 69 6c 65 72 20 77 |NSI C co|mpiler w|
|00004630| 69 6c 6c 20 6f 66 20 63 | 6f 75 72 73 65 20 66 61 |ill of c|ourse fa|
|00004640| 69 6c 2e 20 20 54 68 69 | 73 20 69 73 20 6f 62 76 |il. Thi|s is obv|
|00004650| 69 6f 75 73 6c 79 20 6e | 6f 74 20 61 20 72 65 63 |iously n|ot a rec|
|00004660| 6f 6d 6d 65 6e 64 65 64 | 20 70 72 6f 67 72 61 6d |ommended| program|
|00004670| 6d 69 6e 67 20 70 72 61 | 63 74 69 63 65 2c 20 62 |ming pra|ctice, b|
|00004680| 75 74 20 69 66 20 79 6f | 75 20 61 72 65 20 70 6f |ut if yo|u are po|
|00004690| 72 74 69 6e 67 20 6f 6c | 64 20 43 20 63 6f 64 65 |rting ol|d C code|
|000046a0| 20 79 6f 75 20 6d 61 79 | 20 65 6e 63 6f 75 6e 74 | you may| encount|
|000046b0| 65 72 20 74 68 69 73 20 | 75 73 61 67 65 2e 0d 00 |er this |usage...|
|000046c0| 00 06 00 00 0c 00 00 15 | 00 01 0d 00 00 06 00 00 |........|........|
|000046d0| 0c 00 00 15 00 43 09 57 | 6f 72 6b 61 72 6f 75 6e |.....C.W|orkaroun|
|000046e0| 64 3a 20 20 41 4c 57 41 | 59 53 20 75 73 65 20 74 |d: ALWA|YS use t|
|000046f0| 68 65 20 64 65 63 6c 61 | 72 61 74 69 6f 6e 20 65 |he decla|ration e|
|00004700| 78 74 65 72 6e 20 63 68 | 61 72 20 73 5b 5d 3b 20 |xtern ch|ar s[]; |
|00004710| 69 6e 73 74 65 61 64 2e | 0d 00 00 18 00 00 0c 01 |instead.|........|
|00004720| 00 15 00 0c 0c 00 00 15 | 00 29 0c 00 00 16 00 39 |........|.).....9|
|00004730| 0c 00 00 15 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |........|........|
|00004740| 00 24 01 e6 03 0a 00 00 | 00 12 00 31 00 5a 00 82 |.$......|...1.Z..|
|00004750| 00 a6 00 cf 00 f7 01 20 | 01 48 01 71 01 99 02 10 |....... |.H.q....|
|00004760| 02 10 00 01 0d 2c 00 06 | 00 00 0c 00 00 15 47 49 |.....,..|......GI|
|00004770| 43 50 49 43 11 01 ff 96 | 02 05 39 29 09 41 6e 6f |CPIC....|..9).Ano|
|00004780| 74 68 65 72 20 69 6e 73 | 74 61 6e 63 65 20 77 68 |ther ins|tance wh|
|00004790| 65 72 65 20 64 65 63 6c | 61 72 61 74 69 6f 6e 73 |ere decl|arations|
|000047a0| 20 6f 66 20 74 68 65 20 | 66 6f 72 6d 20 74 79 70 | of the |form typ|
|000047b0| 65 20 73 5b 5d 3b 20 28 | 61 73 20 61 6e 20 61 72 |e s[]; (|as an ar|
|000047c0| 72 61 79 20 6f 66 20 75 | 6e 73 70 65 63 69 66 69 |ray of u|nspecifi|
|000047d0| 65 64 20 6c 65 6e 67 74 | 68 29 20 6d 61 79 20 6e |ed lengt|h) may n|
|000047e0| 6f 74 20 62 65 68 61 76 | 65 20 61 73 20 65 78 70 |ot behav|e as exp|
|000047f0| 65 63 74 65 64 2c 20 69 | 73 20 61 73 20 61 20 6d |ected, i|s as a m|
|00004800| 65 6d 62 65 72 20 6f 66 | 20 61 20 73 74 72 75 63 |ember of| a struc|
|00004810| 74 20 6f 72 20 75 6e 69 | 6f 6e 2e 20 50 72 65 20 |t or uni|on. Pre |
|00004820| 41 4e 53 49 20 63 6f 6d | 70 69 6c 65 72 73 20 6f |ANSI com|pilers o|
|00004830| 66 74 65 6e 20 65 78 70 | 61 6e 64 20 73 75 63 68 |ften exp|and such|
|00004840| 20 64 65 63 6c 61 72 61 | 74 69 6f 6e 73 20 69 6e | declara|tions in|
|00004850| 74 6f 20 74 68 65 20 65 | 71 75 69 76 61 6c 65 6e |to the e|quivalen|
|00004860| 74 20 6f 66 20 61 20 70 | 6f 69 6e 74 65 72 20 64 |t of a p|ointer d|
|00004870| 65 63 6c 61 72 61 74 69 | 6f 6e 2e 20 54 68 69 73 |eclarati|on. This|
|00004880| 20 63 6f 6e 73 74 72 75 | 63 74 20 69 73 20 65 78 | constru|ct is ex|
|00004890| 70 6c 69 63 69 74 6c 79 | 20 70 72 6f 68 69 62 69 |plicitly| prohibi|
|000048a0| 74 65 64 20 69 6e 20 41 | 4e 53 49 20 43 20 73 74 |ted in A|NSI C st|
|000048b0| 72 75 63 74 75 72 65 73 | 20 61 6e 64 20 75 6e 69 |ructures| and uni|
|000048c0| 6f 6e 73 2e 20 4d 50 57 | 20 32 2e 30 2e 32 20 43 |ons. MPW| 2.0.2 C|
|000048d0| 20 6f 6e 20 74 68 65 20 | 6f 74 68 65 72 20 68 61 | on the |other ha|
|000048e0| 6e 64 2c 20 69 73 73 75 | 65 73 20 6e 6f 20 77 61 |nd, issu|es no wa|
|000048f0| 72 6e 69 6e 67 20 61 6e | 64 20 74 72 65 61 74 73 |rning an|d treats|
|00004900| 20 74 68 69 73 20 63 6f | 6e 73 74 72 75 63 74 20 | this co|nstruct |
|00004910| 61 73 20 74 68 65 20 64 | 65 63 6c 61 72 61 74 69 |as the d|eclarati|
|00004920| 6f 6e 20 6f 66 20 61 6e | 20 61 72 72 61 79 20 6f |on of an| array o|
|00004930| 66 20 6c 65 6e 67 74 68 | 20 7a 65 72 6f 2c 20 77 |f length| zero, w|
|00004940| 68 69 63 68 20 6f 63 63 | 75 70 69 65 73 20 6e 6f |hich occ|upies no|
|00004950| 20 73 70 61 63 65 20 69 | 6e 20 74 68 65 20 73 74 | space i|n the st|
|00004960| 72 75 63 74 2e 20 49 6e | 20 74 68 65 20 66 6f 6c |ruct. In| the fol|
|00004970| 6c 6f 77 69 6e 67 20 65 | 78 61 6d 70 6c 65 0d 00 |lowing e|xample..|
|00004980| 00 36 00 00 0c 00 00 15 | 00 33 0c 00 00 16 00 3c |.6......|.3.....<|
|00004990| 0c 00 00 15 00 91 0c 00 | 00 16 00 97 0c 00 00 15 |........|........|
|000049a0| 00 9b 0c 00 00 16 00 a0 | 0c 00 00 15 01 e4 0c 00 |........|........|
|000049b0| 00 16 01 ea 0c 00 00 15 | 00 01 0d 00 00 06 00 00 |........|........|
|000049c0| 0c 00 00 15 00 24 01 e6 | 03 0a 00 00 00 12 00 31 |.....$..|.......1|
|000049d0| 00 5a 00 82 00 a6 00 cf | 00 f7 01 20 01 48 01 71 |.Z......|... .H.q|
|000049e0| 01 99 02 26 02 26 00 18 | 09 74 79 70 65 64 65 66 |...&.&..|.typedef|
|000049f0| 20 73 74 72 75 63 74 20 | 20 53 54 31 20 20 7b 0d | struct | ST1 {.|
|00004a00| 00 06 00 00 09 00 00 16 | 00 40 09 20 20 20 20 20 |........|.@. |
|00004a10| 20 20 20 69 6e 74 20 61 | 72 72 61 79 31 5b 5d 3b | int a|rray1[];|
|00004a20| 09 2f 2a 20 5a 65 72 6f | 20 6c 65 6e 67 74 68 20 |./* Zero| length |
|00004a30| 61 72 72 61 79 20 6f 72 | 20 50 74 72 20 74 6f 20 |array or| Ptr to |
|00004a40| 61 72 72 61 79 3f 20 2a | 2f 0d 00 06 00 00 09 00 |array? *|/.......|
|00004a50| 00 16 00 17 09 20 20 20 | 20 20 20 20 20 69 6e 74 |..... | int|
|00004a60| 20 61 72 72 61 79 32 5b | 5d 3b 0d 00 00 06 00 00 | array2[|];......|
|00004a70| 09 00 00 16 00 17 09 20 | 20 20 20 20 20 20 20 69 |....... | i|
|00004a80| 6e 74 20 61 72 72 61 79 | 33 5b 5d 3b 0d 00 00 06 |nt array|3[];....|
|00004a90| 00 00 09 00 00 16 00 07 | 09 7d 53 54 31 3b 0d 00 |........|.}ST1;..|
|00004aa0| 00 06 00 00 09 00 00 16 | 00 02 09 0d 00 06 00 00 |........|........|
|00004ab0| 09 00 00 16 00 08 09 6d | 61 69 6e 28 29 0d 00 06 |.......m|ain()...|
|00004ac0| 00 00 09 00 00 16 00 03 | 09 7b 0d 00 00 06 00 00 |........|.{......|
|00004ad0| 09 00 00 16 00 0a 09 09 | 53 54 31 20 73 31 3b 0d |........|ST1 s1;.|
|00004ae0| 00 06 00 00 09 00 00 16 | 00 12 09 09 69 6e 74 20 |........|....int |
|00004af0| 69 31 2c 20 69 32 2c 20 | 69 33 3b 0d 00 06 00 00 |i1, i2, |i3;.....|
|00004b00| 09 00 00 16 00 03 09 09 | 0d 00 00 06 00 00 09 00 |........|........|
|00004b10| 00 16 00 15 09 09 69 31 | 20 3d 20 73 31 2e 61 72 |......i1| = s1.ar|
|00004b20| 72 61 79 31 5b 30 5d 3b | 0d 00 00 06 00 00 09 00 |ray1[0];|........|
|00004b30| 00 16 00 15 09 09 69 32 | 20 3d 20 73 31 2e 61 72 |......i2| = s1.ar|
|00004b40| 72 61 79 32 5b 30 5d 3b | 0d 00 00 06 00 00 09 00 |ray2[0];|........|
|00004b50| 00 16 00 15 09 09 69 33 | 20 3d 20 73 31 2e 61 72 |......i3| = s1.ar|
|00004b60| 72 61 79 33 5b 30 5d 3b | 0d 00 00 06 00 00 09 00 |ray3[0];|........|
|00004b70| 00 16 00 03 09 7d 0d 00 | 00 06 00 00 09 00 00 16 |.....}..|........|
|00004b80| 00 12 01 e6 03 0a 00 00 | 00 12 00 31 00 5a 00 82 |........|...1.Z..|
|00004b90| 00 a6 00 cf 00 f7 01 20 | 01 48 01 71 01 99 02 26 |....... |.H.q...&|
|00004ba0| 02 26 00 01 0d 00 00 06 | 00 00 0c 00 00 15 02 3e |.&......|.......>|
|00004bb0| 09 74 68 65 20 74 68 72 | 65 65 20 66 69 65 6c 64 |.the thr|ee field|
|00004bc0| 73 20 6f 66 20 74 68 65 | 20 73 74 72 75 63 74 20 |s of the| struct |
|00004bd0| 53 54 31 20 61 72 65 20 | 6c 6f 63 61 74 65 64 20 |ST1 are |located |
|00004be0| 61 74 20 74 68 65 20 73 | 61 6d 65 20 6d 65 6d 6f |at the s|ame memo|
|00004bf0| 72 79 20 6c 6f 63 61 74 | 69 6f 6e 2c 20 61 6e 64 |ry locat|ion, and|
|00004c00| 20 74 68 65 20 61 73 73 | 69 67 6e 6d 65 6e 74 73 | the ass|ignments|
|00004c10| 20 73 68 6f 77 6e 20 77 | 69 6c 6c 20 61 63 74 75 | shown w|ill actu|
|00004c20| 61 6c 6c 79 20 63 6f 70 | 79 20 67 61 72 62 61 67 |ally cop|y garbag|
|00004c30| 65 20 69 6e 74 6f 20 74 | 68 65 20 69 6e 74 65 67 |e into t|he integ|
|00004c40| 65 72 73 2c 20 73 69 6e | 63 65 20 6e 6f 20 73 70 |ers, sin|ce no sp|
|00004c50| 61 63 65 20 77 61 73 20 | 61 6c 6c 6f 63 61 74 65 |ace was |allocate|
|00004c60| 64 20 66 6f 72 20 65 76 | 65 6e 20 74 68 65 20 66 |d for ev|en the f|
|00004c70| 69 72 73 74 20 65 6c 65 | 6d 65 6e 74 20 6f 66 20 |irst ele|ment of |
|00004c80| 74 68 65 20 61 72 72 61 | 79 73 2e 20 20 55 6e 66 |the arra|ys. Unf|
|00004c90| 6f 72 74 75 6e 61 74 65 | 6c 79 2c 20 73 74 72 75 |ortunate|ly, stru|
|00004ca0| 63 74 75 72 65 73 20 63 | 6f 6e 74 61 69 6e 69 6e |ctures c|ontainin|
|00004cb0| 67 20 61 6e 20 61 72 72 | 61 79 20 6f 66 20 75 6e |g an arr|ay of un|
|00004cc0| 73 70 65 63 69 66 69 65 | 64 20 6f 72 20 7a 65 72 |specifie|d or zer|
|00004cd0| 6f 20 6c 65 6e 67 74 68 | 20 61 73 20 74 68 65 20 |o length| as the |
|00004ce0| 66 69 6e 61 6c 20 6d 65 | 6d 62 65 72 20 61 72 65 |final me|mber are|
|00004cf0| 20 73 6f 6d 65 74 69 6d | 65 73 20 75 73 65 64 20 | sometim|es used |
|00004d00| 74 6f 20 69 6e 64 69 63 | 61 74 65 20 61 20 73 74 |to indic|ate a st|
|00004d10| 72 75 63 74 75 72 65 20 | 63 6f 6e 74 61 69 6e 69 |ructure |containi|
|00004d20| 6e 67 20 61 20 76 61 72 | 69 61 62 6c 65 20 6c 65 |ng a var|iable le|
|00004d30| 6e 67 74 68 20 61 72 72 | 61 79 2e 20 57 68 69 6c |ngth arr|ay. Whil|
|00004d40| 65 20 74 68 69 73 20 6d | 61 79 20 62 65 20 75 73 |e this m|ay be us|
|00004d50| 65 66 75 6c 2c 20 69 74 | 20 69 73 20 6e 6f 74 20 |eful, it| is not |
|00004d60| 74 6f 6c 65 72 61 74 65 | 64 20 20 62 79 20 41 4e |tolerate|d by AN|
|00004d70| 53 49 20 43 20 61 6e 64 | 20 74 68 75 73 20 69 73 |SI C and| thus is|
|00004d80| 20 6e 6f 74 20 61 20 72 | 65 63 6f 6d 6d 65 6e 64 | not a r|ecommend|
|00004d90| 65 64 20 70 72 6f 67 72 | 61 6d 6d 69 6e 67 20 70 |ed progr|amming p|
|00004da0| 72 61 63 74 69 63 65 2e | 20 48 6f 77 65 76 65 72 |ractice.| However|
|00004db0| 2c 20 69 66 20 79 6f 75 | 20 61 72 65 20 70 6f 72 |, if you| are por|
|00004dc0| 74 69 6e 67 20 6f 6c 64 | 20 43 20 63 6f 64 65 20 |ting old| C code |
|00004dd0| 79 6f 75 20 6d 61 79 20 | 65 6e 63 6f 75 6e 74 65 |you may |encounte|
|00004de0| 72 20 74 68 69 73 20 75 | 73 61 67 65 2e 0d 00 2a |r this u|sage...*|
|00004df0| 00 00 0c 00 00 15 00 19 | 0c 00 00 16 00 1f 0c 00 |........|........|
|00004e00| 00 15 00 20 0c 00 00 16 | 00 23 0c 00 00 15 00 9b |... ....|.#......|
|00004e10| 0c 04 00 15 00 a3 0c 00 | 00 15 00 01 0d 00 00 06 |........|........|
|00004e20| 00 00 0c 00 00 15 00 a1 | 09 57 6f 72 6b 61 72 6f |........|.Workaro|
|00004e30| 75 6e 64 3a 20 20 41 4c | 57 41 59 53 20 75 73 65 |und: AL|WAYS use|
|00004e40| 20 74 68 65 20 64 65 63 | 6c 61 72 61 74 69 6f 6e | the dec|laration|
|00004e50| 73 20 6f 66 20 74 68 65 | 20 66 6f 72 6d 20 74 79 |s of the| form ty|
|00004e60| 70 65 20 2a 73 3b 2c 20 | 74 79 70 65 20 28 2a 73 |pe *s;, |type (*s|
|00004e70| 29 5b 5d 3b 2c 20 6f 72 | 20 74 79 70 65 20 73 5b |)[];, or| type s[|
|00004e80| 31 5d 20 28 64 65 70 65 | 6e 64 69 6e 67 20 6f 6e |1] (depe|nding on|
|00004e90| 20 74 68 65 20 69 6e 74 | 65 6e 64 65 64 20 6d 65 | the int|ended me|
|00004ea0| 61 6e 69 6e 67 29 20 69 | 6e 20 73 74 72 75 63 74 |aning) i|n struct|
|00004eb0| 75 72 65 73 20 61 6e 64 | 20 75 6e 69 6f 6e 73 20 |ures and| unions |
|00004ec0| 69 6e 73 74 65 61 64 2e | 0d 00 00 30 00 00 0c 01 |instead.|...0....|
|00004ed0| 00 15 00 0c 0c 00 00 15 | 00 36 0c 00 00 16 00 3e |........|.6.....>|
|00004ee0| 0c 00 00 15 00 40 0c 00 | 00 16 00 4c 0c 00 00 15 |.....@..|...L....|
|00004ef0| 00 51 0c 00 00 16 00 5a | 0c 00 00 15 00 01 0d 00 |.Q.....Z|........|
|00004f00| 00 06 00 00 0c 00 00 15 | 00 e4 31 30 29 09 54 68 |........|..10).Th|
|00004f10| 65 20 72 6f 75 74 69 6e | 65 73 20 5f 53 65 74 55 |e routin|es _SetU|
|00004f20| 70 41 35 20 61 6e 64 20 | 5f 52 65 73 74 6f 72 65 |pA5 and |_Restore|
|00004f30| 41 35 20 64 65 73 63 72 | 69 62 65 64 20 69 6e 20 |A5 descr|ibed in |
|00004f40| 74 68 65 20 4f 53 20 55 | 74 69 6c 69 74 69 65 73 |the OS U|tilities|
|00004f50| 20 43 68 61 70 74 65 72 | 20 6f 66 20 49 6e 73 69 | Chapter| of Insi|
|00004f60| 64 65 20 4d 61 63 69 6e | 74 6f 73 68 2c 20 56 6f |de Macin|tosh, Vo|
|00004f70| 6c 75 6d 65 20 49 49 2c | 20 61 72 65 20 6d 69 73 |lume II,| are mis|
|00004f80| 73 69 6e 67 2e 20 20 52 | 65 66 65 72 20 74 6f 20 |sing. R|efer to |
|00004f90| 54 65 63 68 6e 69 63 61 | 6c 20 4e 6f 74 65 20 23 |Technica|l Note #|
|00004fa0| 32 30 38 3a 20 20 53 65 | 74 74 69 6e 67 20 61 6e |208: Se|tting an|
|00004fb0| 64 20 52 65 73 74 6f 72 | 69 6e 67 20 41 35 20 66 |d Restor|ing A5 f|
|00004fc0| 6f 72 20 74 77 6f 20 6e | 65 77 20 72 6f 75 74 69 |or two n|ew routi|
|00004fd0| 6e 65 73 20 77 68 69 63 | 68 20 73 6f 6c 76 65 20 |nes whic|h solve |
|00004fe0| 74 68 69 73 20 70 72 6f | 62 6c 65 6d 2e 0d 00 2a |this pro|blem...*|
|00004ff0| 00 00 0c 00 00 15 00 11 | 0c 00 00 16 00 19 0c 00 |........|........|
|00005000| 00 15 00 1e 0c 00 00 16 | 00 28 0c 00 00 15 00 52 |........|.(.....R|
|00005010| 0c 02 00 15 00 62 0c 00 | 00 15 00 01 0d 00 00 06 |.....b..|........|
|00005020| 00 00 0c 00 00 15 01 18 | 31 31 29 09 48 69 6e 74 |........|11).Hint|
|00005030| 3a 20 20 53 77 69 74 63 | 68 20 73 74 61 74 65 6d |: Switc|h statem|
|00005040| 65 6e 74 73 20 77 69 74 | 68 20 6c 61 72 67 65 20 |ents wit|h large |
|00005050| 6e 75 6d 62 65 72 73 20 | 6f 66 20 63 61 73 65 73 |numbers |of cases|
|00005060| 20 28 6f 76 65 72 20 31 | 30 30 20 6f 72 20 73 6f | (over 1|00 or so|
|00005070| 29 20 63 61 6e 20 74 72 | 69 67 67 65 72 20 74 68 |) can tr|igger th|
|00005080| 65 20 61 70 70 65 61 72 | 61 6e 63 65 20 6f 66 20 |e appear|ance of |
|00005090| 74 68 65 20 4d 50 57 20 | 42 75 6c 6c 64 6f 7a 65 |the MPW |Bulldoze|
|000050a0| 72 20 63 75 72 73 6f 72 | 20 28 73 69 67 6e 61 6c |r cursor| (signal|
|000050b0| 69 6e 67 20 68 65 61 70 | 20 70 75 72 67 69 6e 67 |ing heap| purging|
|000050c0| 20 61 6e 64 20 63 6f 6d | 70 61 63 74 69 6e 67 20 | and com|pacting |
|000050d0| 69 6e 20 70 72 6f 67 72 | 65 73 73 29 2c 20 63 61 |in progr|ess), ca|
|000050e0| 6e 20 63 61 75 73 65 20 | d2 4f 75 74 20 6f 66 20 |n cause |.Out of |
|000050f0| 6d 65 6d 6f 72 79 d3 20 | 65 72 72 6f 72 73 20 66 |memory. |errors f|
|00005100| 72 6f 6d 20 74 68 65 20 | 63 6f 6d 70 69 6c 65 72 |rom the |compiler|
|00005110| 2c 20 6f 72 20 61 74 20 | 6c 65 61 73 74 20 74 61 |, or at |least ta|
|00005120| 6b 65 20 61 20 76 65 72 | 79 20 6c 6f 6e 67 20 74 |ke a ver|y long t|
|00005130| 69 6d 65 20 74 6f 20 63 | 6f 6d 70 69 6c 65 2e 0d |ime to c|ompile..|
|00005140| 00 12 00 00 0c 00 00 15 | 00 fd 0c 04 00 15 01 06 |........|........|
|00005150| 0c 00 00 15 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |........|........|
|00005160| 00 61 09 57 6f 72 6b 61 | 72 6f 75 6e 64 3a 20 20 |.a.Worka|round: |
|00005170| 4c 61 72 67 65 20 73 77 | 69 74 63 68 20 73 74 61 |Large sw|itch sta|
|00005180| 74 65 6d 65 6e 74 73 20 | 63 61 6e 20 62 65 20 73 |tements |can be s|
|00005190| 70 6c 69 74 20 75 70 20 | 69 6e 74 6f 20 73 6d 61 |plit up |into sma|
|000051a0| 6c 6c 65 72 20 6f 6e 65 | 73 20 74 6f 20 61 76 6f |ller one|s to avo|
|000051b0| 69 64 20 74 68 65 73 65 | 20 73 79 6d 70 74 6f 6d |id these| symptom|
|000051c0| 73 2e 0d 00 00 0c 00 00 | 0c 01 00 15 00 0c 0c 00 |s.......|........|
|000051d0| 00 15 00 24 01 e6 03 0a | 00 00 00 12 00 31 00 5a |...$....|.....1.Z|
|000051e0| 00 82 00 a6 00 cf 00 f7 | 01 20 01 48 01 71 01 99 |........|. .H.q..|
|000051f0| 02 26 02 26 00 02 09 0d | 00 06 00 00 09 00 00 16 |.&.&....|........|
|00005200| 47 49 43 50 49 43 11 01 | ff 96 00 01 0d 00 00 06 |GICPIC..|........|
|00005210| 00 00 0c 00 00 15 00 01 | 0d 00 00 06 00 00 0c 00 |........|........|
|00005220| 00 15 00 24 01 e6 03 0a | 00 00 00 12 00 31 00 5a |...$....|.....1.Z|
|00005230| 00 82 00 a6 00 cf 00 f7 | 01 20 01 48 01 71 01 99 |........|. .H.q..|
|00005240| 02 26 02 26 00 10 50 61 | 73 63 61 6c 20 4c 61 6e |.&.&..Pa|scal Lan|
|00005250| 67 75 61 67 65 0d 00 06 | 00 00 0e 01 00 15 00 01 |guage...|........|
|00005260| 0d 00 00 06 00 00 0c 00 | 00 15 00 7d 54 68 65 20 |........|...}The |
|00005270| 66 6f 6c 6c 6f 77 69 6e | 67 20 69 6e 66 6f 72 6d |followin|g inform|
|00005280| 61 74 69 6f 6e 20 61 70 | 70 6c 69 65 73 20 74 6f |ation ap|plies to|
|00005290| 20 74 68 65 20 50 61 73 | 63 61 6c 20 63 6f 6d 70 | the Pas|cal comp|
|000052a0| 69 6c 65 72 20 61 6e 64 | 20 69 74 73 20 61 73 73 |iler and| its ass|
|000052b0| 6f 63 69 61 74 65 64 20 | 6c 69 62 72 61 72 69 65 |ociated |librarie|
|000052c0| 73 20 73 68 69 70 70 65 | 64 20 77 69 74 68 20 74 |s shippe|d with t|
|000052d0| 68 65 20 32 2e 30 2e 32 | 20 76 65 72 73 69 6f 6e |he 2.0.2| version|
|000052e0| 20 6f 66 20 4d 50 57 2e | 0d 00 00 06 00 00 0c 00 | of MPW.|........|
|000052f0| 00 15 00 01 0d 00 00 06 | 00 00 0c 00 00 15 00 12 |........|........|
|00005300| 01 e6 03 0a 00 00 00 12 | 00 31 00 5a 00 82 00 a6 |........|.1.Z....|
|00005310| 00 cf 00 f7 01 20 01 48 | 01 71 01 99 02 26 02 26 |..... .H|.q...&.&|
|00005320| 01 84 31 29 09 54 68 65 | 20 50 61 73 63 61 6c 20 |..1).The| Pascal |
|00005330| 63 6f 6d 70 69 6c 65 72 | 20 67 65 6e 65 72 61 74 |compiler| generat|
|00005340| 65 73 20 69 6e 63 6f 72 | 72 65 63 74 20 63 6f 64 |es incor|rect cod|
|00005350| 65 20 77 68 65 6e 20 61 | 63 63 65 73 73 69 6e 67 |e when a|ccessing|
|00005360| 20 74 68 65 20 65 6c 65 | 6d 65 6e 74 73 20 6f 66 | the ele|ments of|
|00005370| 20 70 61 63 6b 65 64 20 | 42 6f 6f 6c 65 61 6e 20 | packed |Boolean |
|00005380| 61 72 72 61 79 73 20 77 | 69 74 68 20 6d 6f 72 65 |arrays w|ith more|
|00005390| 20 74 68 61 6e 20 33 32 | 37 36 37 20 65 6c 65 6d | than 32|767 elem|
|000053a0| 65 6e 74 73 2e 20 54 68 | 65 20 67 65 6e 65 72 61 |ents. Th|e genera|
|000053b0| 74 65 64 20 63 6f 64 65 | 20 63 6f 6e 74 61 69 6e |ted code| contain|
|000053c0| 73 20 61 6e 20 41 53 52 | 2e 57 20 69 6e 73 74 72 |s an ASR|.W instr|
|000053d0| 75 63 74 69 6f 6e 20 74 | 6f 20 63 6f 6d 70 75 74 |uction t|o comput|
|000053e0| 65 20 74 68 65 20 62 79 | 74 65 20 6f 66 66 73 65 |e the by|te offse|
|000053f0| 74 20 69 6e 74 6f 20 74 | 68 65 20 61 72 72 61 79 |t into t|he array|
|00005400| 2c 20 74 68 69 73 20 6f | 66 20 63 6f 75 72 73 65 |, this o|f course|
|00005410| 20 66 61 69 6c 73 20 66 | 6f 72 20 6e 75 6d 62 65 | fails f|or numbe|
|00005420| 72 73 20 6c 61 72 67 65 | 72 20 74 68 61 6e 20 33 |rs large|r than 3|
|00005430| 32 37 36 37 20 28 24 37 | 46 46 46 29 2e 20 54 68 |2767 ($7|FFF). Th|
|00005440| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 65 78 61 6d |e follow|ing exam|
|00005450| 70 6c 65 2c 20 77 68 69 | 63 68 20 7a 65 72 6f 65 |ple, whi|ch zeroe|
|00005460| 73 20 62 69 74 73 20 66 | 61 72 20 62 65 79 6f 6e |s bits f|ar beyon|
|00005470| 64 20 74 68 65 20 65 6e | 64 20 6f 66 20 74 68 65 |d the en|d of the|
|00005480| 20 61 72 72 61 79 20 69 | 74 73 65 6c 66 2c 20 69 | array i|tself, i|
|00005490| 6c 6c 75 73 74 72 61 74 | 65 73 20 74 68 65 20 65 |llustrat|es the e|
|000054a0| 72 72 6f 72 3a 0d 00 1e | 00 00 0c 00 00 15 00 4f |rror:...|.......O|
|000054b0| 0c 00 00 16 00 5d 0c 00 | 00 15 00 a3 0c 00 00 16 |.....]..|........|
|000054c0| 00 a8 0c 00 00 15 00 01 | 0d 00 00 06 00 00 0c 00 |........|........|
|000054d0| 00 15 00 24 01 e6 03 0a | 00 00 00 12 00 31 00 5a |...$....|.....1.Z|
|000054e0| 00 82 00 a6 00 cf 00 f7 | 01 20 01 48 01 71 01 99 |........|. .H.q..|
|000054f0| 02 10 02 10 00 17 09 50 | 52 4f 47 52 41 4d 20 50 |.......P|ROGRAM P|
|00005500| 61 63 6b 41 72 72 61 79 | 42 75 67 3b 0d 00 00 06 |ackArray|Bug;....|
|00005510| 00 00 09 00 00 16 00 02 | 09 0d 00 06 00 00 09 00 |........|........|
|00005520| 00 16 00 06 09 09 56 41 | 52 0d 00 06 00 00 09 00 |......VA|R.......|
|00005530| 00 16 00 2f 09 09 20 20 | 4d 79 42 69 74 73 3a 09 |.../.. |MyBits:.|
|00005540| 70 61 63 6b 65 64 20 61 | 72 72 61 79 5b 30 2e 2e |packed a|rray[0..|
|00005550| 33 33 30 30 30 5d 20 6f | 66 20 42 6f 6f 6c 65 61 |33000] o|f Boolea|
|00005560| 6e 3b 0d 00 00 06 00 00 | 09 00 00 16 00 02 09 0d |n;......|........|
|00005570| 00 06 00 00 09 00 00 16 | 00 17 09 09 20 20 50 52 |........|.... PR|
|00005580| 4f 43 45 44 55 52 45 20 | 42 61 64 43 6f 64 65 3b |OCEDURE |BadCode;|
|00005590| 0d 00 00 06 00 00 09 00 | 00 16 00 08 09 09 20 20 |........|...... |
|000055a0| 56 41 52 0d 00 06 00 00 | 09 00 00 16 00 0f 09 09 |VAR.....|........|
|000055b0| 09 69 3a 20 6c 6f 6e 67 | 69 6e 74 3b 0d 00 00 06 |.i: long|int;....|
|000055c0| 00 00 09 00 00 16 00 0a | 09 09 20 20 42 45 47 49 |........|.. BEGI|
|000055d0| 4e 0d 00 06 00 00 09 00 | 00 16 00 1a 09 09 09 66 |N.......|.......f|
|000055e0| 6f 72 20 69 20 3a 3d 20 | 30 20 74 6f 20 33 33 30 |or i := |0 to 330|
|000055f0| 30 30 20 64 6f 0d 00 06 | 00 00 09 00 00 16 00 19 |00 do...|........|
|00005600| 09 09 09 20 20 4d 79 42 | 69 74 73 5b 69 5d 20 3a |... MyB|its[i] :|
|00005610| 3d 20 66 61 6c 73 65 3b | 0d 00 00 06 00 00 09 00 |= false;|........|
|00005620| 00 16 00 09 09 09 20 20 | 45 4e 44 3b 0d 00 00 06 |...... |END;....|
|00005630| 00 00 09 00 00 16 00 02 | 09 0d 00 06 00 00 09 00 |........|........|
|00005640| 00 16 00 08 09 09 42 45 | 47 49 4e 0d 00 06 00 00 |......BE|GIN.....|
|00005650| 09 00 00 16 00 0b 09 09 | 09 42 61 64 43 6f 64 65 |........|.BadCode|
|00005660| 0d 00 00 06 00 00 09 00 | 00 16 00 07 09 09 45 4e |........|......EN|
|00005670| 44 2e 0d 00 00 06 00 00 | 09 00 00 16 00 12 01 e6 |D.......|........|
|00005680| 03 0a 00 00 00 12 00 31 | 00 5a 00 82 00 a6 00 cf |.......1|.Z......|
|00005690| 00 f7 01 20 01 48 01 71 | 01 99 02 26 02 26 00 01 |... .H.q|...&.&..|
|000056a0| 0d 00 00 06 00 00 0c 00 | 00 15 00 4d 09 57 6f 72 |........|...M.Wor|
|000056b0| 6b 61 72 6f 75 6e 64 3a | 20 20 44 6f 6e d5 74 20 |karound:| Don.t |
|000056c0| 75 73 65 20 70 61 63 6b | 65 64 20 42 6f 6f 6c 65 |use pack|ed Boole|
|000056d0| 61 6e 20 61 72 72 61 79 | 73 20 77 69 74 68 20 6d |an array|s with m|
|000056e0| 6f 72 65 20 74 68 61 6e | 20 33 32 37 36 37 20 65 |ore than| 32767 e|
|000056f0| 6c 65 6d 65 6e 74 73 2e | 0d 00 00 18 00 00 0c 01 |lements.|........|
|00005700| 00 15 00 0c 0c 00 00 15 | 00 18 0c 00 00 16 00 26 |........|.......&|
|00005710| 0c 00 00 15 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |........|........|
|00005720| 00 c5 32 29 09 54 68 65 | 20 50 61 73 63 61 6c 20 |..2).The| Pascal |
|00005730| 63 6f 6d 70 69 6c 65 72 | 20 66 61 69 6c 73 20 74 |compiler| fails t|
|00005740| 6f 20 64 65 74 65 63 74 | 20 74 68 65 20 73 69 74 |o detect| the sit|
|00005750| 75 61 74 69 6f 6e 20 77 | 68 65 72 65 20 61 20 70 |uation w|here a p|
|00005760| 72 6f 63 65 64 75 72 65 | 20 6e 61 6d 65 20 69 73 |rocedure| name is|
|00005770| 20 70 61 73 73 65 64 20 | 61 73 20 61 6e 20 61 72 | passed |as an ar|
|00005780| 67 75 6d 65 6e 74 20 74 | 6f 20 61 20 72 6f 75 74 |gument t|o a rout|
|00005790| 69 6e 65 20 65 78 70 65 | 63 74 69 6e 67 20 61 20 |ine expe|cting a |
|000057a0| 66 75 6e 63 74 69 6f 6e | 20 61 73 20 61 6e 20 61 |function| as an a|
|000057b0| 72 67 75 6d 65 6e 74 2e | 20 54 68 65 20 66 6f 6c |rgument.| The fol|
|000057c0| 6c 6f 77 69 6e 67 20 65 | 78 61 6d 70 6c 65 20 20 |lowing e|xample |
|000057d0| 69 6c 6c 75 73 74 72 61 | 74 65 73 20 74 68 65 20 |illustra|tes the |
|000057e0| 65 72 72 6f 72 3a 0d 00 | 00 06 00 00 0c 00 00 15 |error:..|........|
|000057f0| 00 01 0d 00 00 06 00 00 | 0c 00 00 15 00 24 01 e6 |........|.....$..|
|00005800| 03 0a 00 00 00 12 00 31 | 00 5a 00 82 00 a6 00 cf |.......1|.Z......|
|00005810| 00 f7 01 20 01 48 01 71 | 01 99 02 10 02 10 00 15 |... .H.q|........|
|00005820| 09 50 52 4f 47 52 41 4d | 20 46 75 6e 63 41 72 67 |.PROGRAM| FuncArg|
|00005830| 42 75 67 3b 0d 00 00 06 | 00 00 09 00 00 16 00 02 |Bug;....|........|
|00005840| 09 0d 00 06 00 00 09 00 | 00 16 00 42 09 09 20 20 |........|...B.. |
|00005850| 50 52 4f 43 45 44 55 52 | 45 20 45 78 70 65 63 74 |PROCEDUR|E Expect|
|00005860| 73 46 75 6e 63 28 78 3a | 20 69 6e 74 65 67 65 72 |sFunc(x:| integer|
|00005870| 3b 20 66 75 6e 63 74 69 | 6f 6e 20 56 69 73 69 74 |; functi|on Visit|
|00005880| 28 79 31 3a 20 6c 6f 6e | 67 69 6e 74 3b 0d 00 06 |(y1: lon|gint;...|
|00005890| 00 00 09 00 00 16 00 1b | 09 09 09 09 20 79 32 3a |........|.... y2:|
|000058a0| 20 63 68 61 72 3b 29 3a | 20 42 6f 6f 6c 65 61 6e | char;):| Boolean|
|000058b0| 29 3b 0d 00 00 06 00 00 | 09 00 00 16 00 08 09 09 |);......|........|
|000058c0| 20 20 56 41 52 0d 00 06 | 00 00 09 00 00 16 00 14 | VAR...|........|
|000058d0| 09 09 09 72 65 73 75 6c | 74 3a 20 42 6f 6f 6c 65 |...resul|t: Boole|
|000058e0| 61 6e 3b 0d 00 06 00 00 | 09 00 00 16 00 0d 09 09 |an;.....|........|
|000058f0| 09 79 63 3a 20 63 68 61 | 72 3b 0d 00 00 06 00 00 |.yc: cha|r;......|
|00005900| 09 00 00 16 00 0a 09 09 | 20 20 42 45 47 49 4e 0d |........| BEGIN.|
|00005910| 00 06 00 00 09 00 00 16 | 00 0e 09 09 09 79 63 20 |........|.....yc |
|00005920| 3a 3d 20 27 41 27 3b 0d | 00 06 00 00 09 00 00 16 |:= 'A';.|........|
|00005930| 00 1b 09 09 09 72 65 73 | 75 6c 74 20 3a 3d 20 56 |.....res|ult := V|
|00005940| 69 73 69 74 28 78 2c 20 | 79 63 29 3b 0d 00 00 06 |isit(x, |yc);....|
|00005950| 00 00 09 00 00 16 00 09 | 09 09 20 20 45 4e 44 3b |........|.. END;|
|00005960| 0d 00 00 06 00 00 09 00 | 00 16 00 02 09 0d 00 06 |........|........|
|00005970| 00 00 09 00 00 16 00 32 | 09 09 20 20 50 52 4f 43 |.......2|.. PROC|
|00005980| 45 44 55 52 45 20 46 6f | 72 6d 61 6c 50 72 6f 63 |EDURE Fo|rmalProc|
|00005990| 28 79 31 3a 20 6c 6f 6e | 67 69 6e 74 3b 20 79 32 |(y1: lon|gint; y2|
|000059a0| 3a 20 63 68 61 72 3b 29 | 3b 0d 00 06 00 00 09 00 |: char;)|;.......|
|000059b0| 00 16 00 0a 09 09 20 20 | 42 45 47 49 4e 0d 00 06 |...... |BEGIN...|
|000059c0| 00 00 09 00 00 16 00 1c | 09 09 09 77 72 69 74 65 |........|...write|
|000059d0| 6c 6e 28 79 31 3a 20 31 | 2c 20 27 20 27 2c 20 79 |ln(y1: 1|, ' ', y|
|000059e0| 32 29 3b 0d 00 06 00 00 | 09 00 00 16 00 09 09 09 |2);.....|........|
|000059f0| 20 20 45 4e 44 3b 0d 00 | 00 06 00 00 09 00 00 16 | END;..|........|
|00005a00| 00 02 09 0d 00 06 00 00 | 09 00 00 16 00 08 09 09 |........|........|
|00005a10| 42 45 47 49 4e 0d 00 06 | 00 00 09 00 00 16 00 1f |BEGIN...|........|
|00005a20| 09 09 09 45 78 70 65 63 | 74 73 46 75 6e 63 28 35 |...Expec|tsFunc(5|
|00005a30| 2c 20 46 6f 72 6d 61 6c | 50 72 6f 63 29 3b 0d 00 |, Formal|Proc);..|
|00005a40| 00 06 00 00 09 00 00 16 | 00 07 09 09 45 4e 44 2e |........|....END.|
|00005a50| 0d 00 00 06 00 00 09 00 | 00 16 00 12 01 e6 03 0a |........|........|
|00005a60| 00 00 00 12 00 31 00 5a | 00 82 00 a6 00 cf 00 f7 |.....1.Z|........|
|00005a70| 01 20 01 48 01 71 01 99 | 02 26 02 26 00 01 0d 00 |. .H.q..|.&.&....|
|00005a80| 00 06 00 00 0c 00 00 15 | 00 55 09 54 68 69 73 20 |........|.U.This |
|00005a90| 74 79 70 65 20 6f 66 20 | 70 72 6f 62 6c 65 6d 20 |type of |problem |
|00005aa0| 74 79 70 69 63 61 6c 6c | 79 20 6c 65 61 64 73 20 |typicall|y leads |
|00005ab0| 74 6f 20 73 74 61 63 6b | 20 6d 69 73 61 6c 69 67 |to stack| misalig|
|00005ac0| 6e 6d 65 6e 74 20 61 6e | 64 20 73 70 65 63 74 61 |nment an|d specta|
|00005ad0| 63 75 6c 61 72 20 63 72 | 61 73 68 65 73 2e 0d 00 |cular cr|ashes...|
|00005ae0| 00 06 00 00 0c 00 00 15 | 00 01 0d 00 00 06 00 00 |........|........|
|00005af0| 0c 00 00 15 00 6e 09 57 | 6f 72 6b 61 72 6f 75 6e |.....n.W|orkaroun|
|00005b00| 64 3a 20 20 4d 61 6b 65 | 20 63 65 72 74 61 69 6e |d: Make| certain|
|00005b10| 20 74 68 61 74 20 50 61 | 73 63 61 6c 20 72 6f 75 | that Pa|scal rou|
|00005b20| 74 69 6e 65 73 20 65 78 | 70 65 63 74 69 6e 67 20 |tines ex|pecting |
|00005b30| 66 75 6e 63 74 69 6f 6e | 73 20 61 73 20 61 72 67 |function|s as arg|
|00005b40| 75 6d 65 6e 74 73 20 61 | 72 65 20 69 6e 64 65 65 |uments a|re indee|
|00005b50| 64 20 70 61 73 73 65 64 | 20 66 75 6e 63 74 69 6f |d passed| functio|
|00005b60| 6e 73 2e 0d 00 0c 00 00 | 0c 01 00 15 00 0c 0c 00 |ns......|........|
|00005b70| 00 15 00 01 0d 00 00 06 | 00 00 0c 00 00 15 01 87 |........|........|
|00005b80| 33 29 09 54 68 65 20 2d | 6d 63 36 38 38 38 31 20 |3).The -|mc68881 |
|00005b90| 6f 70 74 69 6f 6e 20 63 | 61 75 73 65 73 20 74 68 |option c|auses th|
|00005ba0| 65 20 50 61 73 63 61 6c | 20 63 6f 6d 70 69 6c 65 |e Pascal| compile|
|00005bb0| 72 20 74 6f 20 67 65 6e | 65 72 61 74 65 20 69 6e |r to gen|erate in|
|00005bc0| 63 6f 72 72 65 63 74 20 | 63 6f 64 65 20 77 68 65 |correct |code whe|
|00005bd0| 6e 20 63 61 6c 6c 69 6e | 67 20 65 78 74 65 72 6e |n callin|g extern|
|00005be0| 61 6c 20 43 20 6c 61 6e | 67 75 61 67 65 20 72 6f |al C lan|guage ro|
|00005bf0| 75 74 69 6e 65 73 20 77 | 69 74 68 20 66 6c 6f 61 |utines w|ith floa|
|00005c00| 74 69 6e 67 20 70 6f 69 | 6e 74 20 65 78 74 65 6e |ting poi|nt exten|
|00005c10| 64 65 64 20 61 72 67 75 | 6d 65 6e 74 73 2e 20 41 |ded argu|ments. A|
|00005c20| 70 70 61 72 65 6e 74 6c | 79 20 74 68 65 20 63 6f |pparentl|y the co|
|00005c30| 6d 70 69 6c 65 72 20 6d | 69 73 63 61 6c 63 75 6c |mpiler m|iscalcul|
|00005c40| 61 74 65 73 20 74 68 65 | 20 73 69 7a 65 20 6f 66 |ates the| size of|
|00005c50| 20 74 68 65 20 65 78 74 | 65 6e 64 65 64 20 61 72 | the ext|ended ar|
|00005c60| 67 75 6d 65 6e 74 20 73 | 6f 20 74 68 61 74 20 69 |gument s|o that i|
|00005c70| 74 20 69 6e 63 6f 72 72 | 65 63 74 6c 79 20 72 65 |t incorr|ectly re|
|00005c80| 6d 6f 76 65 73 20 74 68 | 65 20 61 72 67 75 6d 65 |moves th|e argume|
|00005c90| 6e 74 73 20 66 72 6f 6d | 20 74 68 65 20 73 74 61 |nts from| the sta|
|00005ca0| 63 6b 2e 20 54 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |ck. The |followin|
|00005cb0| 67 20 65 78 61 6d 70 6c | 65 2c 20 77 68 69 63 68 |g exampl|e, which|
|00005cc0| 20 63 61 6e 20 63 6f 72 | 72 75 70 74 20 74 68 65 | can cor|rupt the|
|00005cd0| 20 6c 6f 63 61 6c 20 76 | 61 72 69 61 62 6c 65 73 | local v|ariables|
|00005ce0| 20 6f 66 20 69 74 73 20 | 63 61 6c 6c 65 72 2c 20 | of its |caller, |
|00005cf0| 69 6c 6c 75 73 74 72 61 | 74 65 73 20 74 68 65 20 |illustra|tes the |
|00005d00| 65 72 72 6f 72 3a 0d 00 | 00 2a 00 00 0c 00 00 15 |error:..|.*......|
|00005d10| 00 07 0c 00 00 16 00 0f | 0c 00 00 15 00 8b 0c 00 |........|........|
|00005d20| 00 16 00 93 0c 00 00 15 | 00 d5 0c 00 00 16 00 dd |........|........|
|00005d30| 0c 00 00 15 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |........|........|
|00005d40| 00 24 01 e6 03 0a 00 00 | 00 12 00 31 00 5a 00 82 |.$......|...1.Z..|
|00005d50| 00 a6 00 cf 00 f7 01 20 | 01 48 01 71 01 99 02 10 |....... |.H.q....|
|00005d60| 02 10 00 2f 09 46 55 4e | 43 54 49 4f 4e 20 45 32 |.../.FUN|CTION E2|
|00005d70| 53 28 66 3a 20 53 74 72 | 32 35 35 3b 20 78 3a 20 |S(f: Str|255; x: |
|00005d80| 65 78 74 65 6e 64 65 64 | 29 3a 20 53 74 72 32 35 |extended|): Str25|
|00005d90| 35 3b 0d 00 00 06 00 00 | 09 00 00 16 00 08 09 20 |5;......|....... |
|00005da0| 20 20 56 41 52 0d 00 06 | 00 00 09 00 00 16 00 12 | VAR...|........|
|00005db0| 09 09 64 75 6d 6d 79 3a | 20 69 6e 74 65 67 65 72 |..dummy:| integer|
|00005dc0| 3b 0d 00 06 00 00 09 00 | 00 16 00 0f 09 09 69 3a |;.......|......i:|
|00005dd0| 09 20 69 6e 74 65 67 65 | 72 3b 0d 00 00 06 00 00 |. intege|r;......|
|00005de0| 09 00 00 16 00 0e 09 09 | 74 3a 09 20 53 74 72 32 |........|t:. Str2|
|00005df0| 35 35 3b 0d 00 06 00 00 | 09 00 00 16 00 05 09 09 |55;.....|........|
|00005e00| 09 09 0d 00 00 06 00 00 | 09 00 00 16 00 4d 09 20 |........|.....M. |
|00005e10| 20 46 55 4e 43 54 49 4f | 4e 20 73 70 72 69 6e 74 | FUNCTIO|N sprint|
|00005e20| 66 28 73 74 72 3a 20 50 | 74 72 3b 20 66 6d 74 3a |f(str: P|tr; fmt:|
|00005e30| 20 50 74 72 3b 20 78 3a | 20 65 78 74 65 6e 64 65 | Ptr; x:| extende|
|00005e40| 64 29 3a 20 69 6e 74 65 | 67 65 72 3b 20 43 3b 20 |d): inte|ger; C; |
|00005e50| 45 58 54 45 52 4e 41 4c | 3b 09 0d 00 00 06 00 00 |EXTERNAL|;.......|
|00005e60| 09 00 00 16 00 02 09 0d | 00 06 00 00 09 00 00 16 |........|........|
|00005e70| 00 09 09 20 20 42 45 47 | 49 4e 0d 00 00 06 00 00 |... BEG|IN......|
|00005e80| 09 00 00 16 00 12 09 09 | 74 5b 30 5d 20 3a 3d 20 |........|t[0] := |
|00005e90| 63 68 72 28 30 29 3b 0d | 00 06 00 00 09 00 00 16 |chr(0);.|........|
|00005ea0| 00 1d 09 09 66 5b 6f 72 | 64 28 66 5b 30 5d 29 20 |....f[or|d(f[0]) |
|00005eb0| 2b 31 5d 20 3a 3d 20 63 | 68 72 28 30 29 3b 0d 00 |+1] := c|hr(0);..|
|00005ec0| 00 06 00 00 09 00 00 16 | 00 02 09 0d 00 06 00 00 |........|........|
|00005ed0| 09 00 00 16 00 25 09 09 | 64 75 6d 6d 79 20 3a 3d |.....%..|dummy :=|
|00005ee0| 20 73 70 72 69 6e 74 66 | 28 40 74 5b 31 5d 2c 20 | sprintf|(@t[1], |
|00005ef0| 40 66 5b 31 5d 2c 20 78 | 29 3b 0d 00 00 06 00 00 |@f[1], x|);......|
|00005f00| 09 00 00 16 00 02 09 0d | 00 06 00 00 09 00 00 16 |........|........|
|00005f10| 00 0a 09 09 69 20 3a 3d | 20 30 3b 0d 00 06 00 00 |....i :=| 0;.....|
|00005f20| 09 00 00 16 00 09 09 09 | 72 65 70 65 61 74 0d ff |........|repeat..|
|00005f30| 00 06 00 00 09 00 00 16 | 00 0e 09 09 20 20 69 20 |........|.... i |
|00005f40| 3a 3d 20 69 2b 31 3b 0d | 00 06 00 00 09 00 00 16 |:= i+1;.|........|
|00005f50| 00 28 09 09 75 6e 74 69 | 6c 20 28 28 74 5b 69 5d |.(..unti|l ((t[i]|
|00005f60| 20 3d 20 63 68 72 28 30 | 29 29 20 6f 72 20 28 69 | = chr(0|)) or (i|
|00005f70| 20 3e 20 32 35 34 29 29 | 3b 0d 00 06 00 00 09 00 | > 254))|;.......|
|00005f80| 00 16 00 12 09 09 74 5b | 30 5d 20 3a 3d 20 63 68 |......t[|0] := ch|
|00005f90| 72 28 69 29 3b 0d 00 06 | 00 00 09 00 00 16 00 02 |r(i);...|........|
|00005fa0| 09 0d 00 06 00 00 09 00 | 00 16 00 0c 09 09 45 32 |........|......E2|
|00005fb0| 53 20 3a 3d 20 74 3b 0d | 00 06 00 00 09 00 00 16 |S := t;.|........|
|00005fc0| 00 08 09 20 20 45 4e 44 | 2e 0d 00 06 00 00 09 00 |... END|........|
|00005fd0| 00 16 00 12 01 e6 03 0a | 00 00 00 12 00 31 00 5a |........|.....1.Z|
|00005fe0| 00 82 00 a6 00 cf 00 f7 | 01 20 01 48 01 71 01 99 |........|. .H.q..|
|00005ff0| 02 26 02 26 00 01 0d 00 | 00 06 00 00 0c 00 00 15 |.&.&....|........|
|00006000| 00 32 09 54 68 65 20 72 | 65 6c 65 76 61 6e 74 20 |.2.The r|elevant |
|00006010| 70 6f 72 74 69 6f 6e 73 | 20 6f 66 20 74 68 65 20 |portions| of the |
|00006020| 67 65 6e 65 72 61 74 65 | 64 20 63 6f 64 65 20 61 |generate|d code a|
|00006030| 72 65 3a 0d 00 06 00 00 | 0c 00 00 15 00 01 0d 00 |re:.....|........|
|00006040| 00 06 00 00 0c 00 00 15 | 00 24 01 e6 03 0a 00 00 |........|.$......|
|00006050| 00 12 00 31 00 5a 00 82 | 00 a6 00 cf 00 f7 01 20 |...1.Z..|....... |
|00006060| 01 48 01 71 01 99 02 26 | 02 26 00 2c 09 4c 49 4e |.H.q...&|.&.,.LIN|
|00006070| 4b 20 20 20 20 20 20 20 | 41 36 2c 23 24 46 44 46 |K |A6,#$FDF|
|00006080| 30 09 3b 20 4c 49 4e 4b | 20 66 6f 72 20 6c 6f 63 |0.; LINK| for loc|
|00006090| 61 6c 20 76 61 72 73 0d | 00 06 00 00 09 00 00 16 |al vars.|........|
|000060a0| 00 33 09 4d 4f 56 45 4d | 2e 4c 20 20 20 20 44 36 |.3.MOVEM|.L D6|
|000060b0| 2f 44 37 2c 2d 28 41 37 | 29 09 3b 20 53 61 76 65 |/D7,-(A7|).; Save|
|000060c0| 20 52 65 67 69 73 74 65 | 72 73 20 75 73 65 64 20 | Registe|rs used |
|000060d0| 68 65 72 65 0d 00 00 06 | 00 00 09 00 00 16 00 05 |here....|........|
|000060e0| 09 2e 2e 2e 0d ff 00 06 | 00 00 09 00 00 16 00 05 |........|........|
|000060f0| 09 2e 2e 2e 0d 00 00 06 | 00 00 09 00 00 16 00 37 |........|.......7|
|00006100| 09 4c 45 41 20 20 20 20 | 20 20 20 20 24 46 46 30 |.LEA | $FF0|
|00006110| 30 28 41 36 29 2c 41 30 | 09 3b 20 47 65 74 20 61 |0(A6),A0|.; Get a|
|00006120| 64 64 72 65 73 73 20 6f | 66 20 65 78 74 65 6e 64 |ddress o|f extend|
|00006130| 65 64 20 76 61 72 0d 00 | 00 06 00 00 09 00 00 16 |ed var..|........|
|00006140| 00 33 09 4d 4f 56 45 2e | 4c 20 20 20 20 20 2d 28 |.3.MOVE.|L -(|
|00006150| 41 30 29 2c 2d 28 41 37 | 29 09 3b 20 50 75 73 68 |A0),-(A7|).; Push|
|00006160| 20 65 78 74 65 6e 64 65 | 64 20 6f 6e 74 6f 20 73 | extende|d onto s|
|00006170| 74 61 63 6b 0d 00 00 06 | 00 00 09 00 00 16 00 18 |tack....|........|
|00006180| 09 4d 4f 56 45 2e 4c 20 | 20 20 20 20 2d 28 41 30 |.MOVE.L | -(A0|
|00006190| 29 2c 2d 28 41 37 29 0d | 00 06 00 00 09 00 00 16 |),-(A7).|........|
|000061a0| 00 18 09 4d 4f 56 45 2e | 4c 20 20 20 20 20 2d 28 |...MOVE.|L -(|
|000061b0| 41 30 29 2c 2d 28 41 37 | 29 0d 00 06 00 00 09 00 |A0),-(A7|).......|
|000061c0| 00 16 00 33 09 50 45 41 | 20 20 20 20 20 20 20 20 |...3.PEA| |
|000061d0| 24 46 46 30 31 28 41 36 | 29 09 3b 20 50 75 73 68 |$FF01(A6|).; Push|
|000061e0| 20 61 64 64 72 65 73 73 | 20 6f 66 20 66 6f 72 6d | address| of form|
|000061f0| 61 74 20 73 74 72 0d ff | 00 06 00 00 09 00 00 16 |at str..|........|
|00006200| 00 33 09 50 45 41 20 20 | 20 20 20 20 20 20 24 46 |.3.PEA | $F|
|00006210| 44 46 31 28 41 36 29 09 | 3b 20 50 75 73 68 20 61 |DF1(A6).|; Push a|
|00006220| 64 64 72 65 73 73 20 6f | 66 20 74 61 72 67 65 74 |ddress o|f target|
|00006230| 20 73 74 72 0d ff 00 06 | 00 00 09 00 00 16 00 25 | str....|.......%|
|00006240| 09 4a 53 52 20 20 20 20 | 20 20 20 20 2a 2b 24 30 |.JSR | *+$0|
|00006250| 30 30 32 09 3b 20 4a 53 | 52 20 74 6f 20 73 70 72 |002.; JS|R to spr|
|00006260| 69 6e 74 66 0d 00 00 06 | 00 00 09 00 00 16 00 2f |intf....|......./|
|00006270| 09 4c 45 41 20 20 20 20 | 20 20 20 20 24 30 30 31 |.LEA | $001|
|00006280| 32 28 41 37 29 2c 41 37 | 09 3b 20 50 6f 70 20 61 |2(A7),A7|.; Pop a|
|00006290| 72 67 73 20 6f 66 66 20 | 73 74 61 63 6b 20 0d 00 |rgs off |stack ..|
|000062a0| 00 06 00 00 09 00 00 16 | 00 20 09 09 3b 20 28 53 |........|. ..; (S|
|000062b0| 48 4f 55 4c 44 20 70 6f | 70 20 6f 66 66 20 24 31 |HOULD po|p off $1|
|000062c0| 34 20 62 79 74 65 73 21 | 29 0d 00 06 00 00 09 00 |4 bytes!|).......|
|000062d0| 00 16 00 29 09 4d 4f 56 | 45 2e 57 20 20 20 20 20 |...).MOV|E.W |
|000062e0| 44 30 2c 44 36 09 3b 20 | 53 61 76 65 20 66 75 6e |D0,D6.; |Save fun|
|000062f0| 63 74 69 6f 6e 20 72 65 | 73 75 6c 74 0d 00 00 06 |ction re|sult....|
|00006300| 00 00 09 00 00 16 00 05 | 09 2e 2e 2e 0d 00 00 06 |........|........|
|00006310| 00 00 09 00 00 16 00 05 | 09 2e 2e 2e 0d 00 00 06 |........|........|
|00006320| 00 00 09 00 00 16 00 36 | 09 4d 4f 56 45 4d 2e 4c |.......6|.MOVEM.L|
|00006330| 20 20 20 20 28 41 37 29 | 2b 2c 44 36 2f 44 37 09 | (A7)|+,D6/D7.|
|00006340| 3b 20 52 65 73 74 6f 72 | 65 20 72 65 67 69 73 74 |; Restor|e regist|
|00006350| 65 72 73 20 75 73 65 64 | 20 68 65 72 65 0d 00 06 |ers used| here...|
|00006360| 00 00 09 00 00 16 00 23 | 09 09 3b 20 20 28 4e 6f |.......#|..; (No|
|00006370| 77 20 74 68 65 79 27 76 | 65 20 62 65 65 6e 20 63 |w they'v|e been c|
|00006380| 6f 72 72 75 70 74 65 64 | 21 29 0d 00 00 06 00 00 |orrupted|!)......|
|00006390| 09 00 00 16 00 27 09 55 | 4e 4c 4b 20 20 20 20 20 |.....'.U|NLK |
|000063a0| 20 20 41 36 09 3b 20 43 | 6f 72 72 65 63 74 6c 79 | A6.; C|orrectly|
|000063b0| 20 72 65 73 74 6f 72 65 | 73 20 41 37 0d ff 00 06 | restore|s A7....|
|000063c0| 00 00 09 00 00 16 00 15 | 09 4d 4f 56 45 41 2e 4c |........|.MOVEA.L|
|000063d0| 20 20 20 20 28 41 37 29 | 2b 2c 41 30 0d 00 00 06 | (A7)|+,A0....|
|000063e0| 00 00 09 00 00 16 00 13 | 09 41 44 44 51 2e 57 20 |........|.ADDQ.W |
|000063f0| 20 20 20 20 23 24 38 2c | 41 37 0d ff 00 06 00 00 | #$8,|A7......|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.